Recent

Author Topic: StringGrid and cbs.....  (Read 16669 times)

asdf

  • Sr. Member
  • ****
  • Posts: 310
StringGrid and cbs.....
« on: November 08, 2010, 08:58:36 am »
1. Could StringGrid shows cbsButton, cbsEllipsis and cbsPickList at all times like cbsCheckBoxColumn ? Not only when double click to edit cell data.

2. How can we protect the cells with cbsPickList by using only values in PickList?
    I noticed that I could edit the value by using the keyboard.
Lazarus 1.2.4 / Win 32 / THAILAND

tk

  • Sr. Member
  • ****
  • Posts: 368
Re: StringGrid and cbs.....
« Reply #1 on: November 08, 2010, 03:31:38 pm »
In KGrid:
1. You have to paint it in OnDrawCell.
2. You can assign your own combo box with csDropDownList style as inplace editor.

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: StringGrid and cbs.....
« Reply #2 on: November 10, 2010, 05:22:25 pm »
By upgrading to v0.9.29, now I've got 1. already  :D .
But how can I add a tiny picture with text on the buttons  :-\ ?

Using cbs...., Grid must be +[goediting].
For cbsPickList, how can I setup the cell to accept "only" a value from PickList?
Lazarus 1.2.4 / Win 32 / THAILAND

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: StringGrid and cbs.....
« Reply #3 on: November 12, 2010, 04:38:02 pm »
How can we put a tiny picture with text on the buttons  :-\ ?

Using cbs...., Grid must be +[goediting].
For cbsPickList, how can I setup the cell to accept "only" a value from PickList?
Lazarus 1.2.4 / Win 32 / THAILAND

jesusr

  • Sr. Member
  • ****
  • Posts: 496
Re: StringGrid and cbs.....
« Reply #4 on: November 13, 2010, 06:06:49 pm »
You can use grid event OnDrawCell to draw anything over the button. About the picklist question, see this example:  http://wiki.lazarus.freepascal.org/Grids_Reference_Page#Example:_Working_with_Picklist.2C_How_to_make_it_read_only_and_How_to_fill_it_at_run_time.

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: StringGrid and cbs.....
« Reply #5 on: December 23, 2010, 12:17:07 pm »
About the picklist question, see this example:  http://wiki.lazarus.freepascal.org/Grids_Reference_Page#Example:_Working_with_Picklist.2C_How_to_make_it_read_only_and_How_to_fill_it_at_run_time.

In this example, is there anything to write more ?
I added StringGrid1 into Form1 then StringGrid1.Columns.Add ... but StringGrid1 still stood silent.
Lazarus 1.2.4 / Win 32 / THAILAND

jesusr

  • Sr. Member
  • ****
  • Posts: 496
Re: StringGrid and cbs.....
« Reply #6 on: December 23, 2010, 10:31:59 pm »
Quote
I added StringGrid1 into Form1 then StringGrid1.Columns.Add ... but StringGrid1 still stood silent.

Then you have added a custom column which is what StringGrid1.Columns.Add returns, then you need to change the custom column property ButtonStyle to cbsPickList

Code: [Select]
var
  C := TGridColumn;
....
   C := StringGrid1.Columns.Add;
   C.ButtonStyle := cbsPicklist;
....
or

Code: [Select]
   with StringGrid1.Columns.Add do begin
      ButtonStyle := cbsPickList;
   end;

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: StringGrid and cbs.....
« Reply #7 on: December 25, 2010, 06:46:11 pm »
procedure TForm1.FormCreate(Sender: TObject);
begin
stringgrid1.Columns.Add;
stringgrid1.Columns.Add;
stringgrid1.Columns[0].ButtonStyle:=cbspicklist;
stringgrid1.Options:=stringgrid1.Options+[goediting];
end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject; aCol, aRow: Integer;
  var CanSelect: Boolean);
begin
  if (aCol=1) and (aRow<>3) then CanSelect := true;
end;

procedure TForm1.StringGrid1SelectEditor(Sender: TObject; aCol, aRow: Integer;
          var Editor: TWinControl);
begin
//  if (aCol=1) and (aRow<>3) then begin Editor := nil; // How about this line ?
//end;
//procedure TForm1.gridSelectEditor(Sender: TObject; aCol, aRow: Integer;
//  var Editor: TWinControl);
//begin
  if (aCol=1) and (aRow<>3) then begin
    if (Editor is TCustomComboBox) then // Error: Identifier not found 'TCustomComboBox'
« Last Edit: December 25, 2010, 06:48:25 pm by asdf »
Lazarus 1.2.4 / Win 32 / THAILAND

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: StringGrid and cbs.....
« Reply #8 on: December 30, 2010, 11:04:37 am »
    if (Editor is TCustomComboBox) then

There was an error Error: Identifier not found 'TCustomComboBox'.
Lazarus 1.2.4 / Win 32 / THAILAND

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: StringGrid and cbs.....
« Reply #9 on: January 06, 2011, 06:59:48 am »
Help me please  :'( .
Lazarus 1.2.4 / Win 32 / THAILAND

Laksen

  • Hero Member
  • *****
  • Posts: 794
    • J-Software
Re: StringGrid and cbs.....
« Reply #10 on: January 06, 2011, 07:38:24 am »
Try including the stdctrls unit

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: StringGrid and cbs.....
« Reply #11 on: January 06, 2011, 04:14:24 pm »
Now it worked with latest SVN.
I have used StdCtrls since the beginning.

Thank you so much
« Last Edit: January 06, 2011, 04:16:55 pm by asdf »
Lazarus 1.2.4 / Win 32 / THAILAND

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: StringGrid and cbs.....
« Reply #12 on: January 13, 2011, 04:59:45 am »
You can use grid event OnDrawCell to draw anything over the button.

And
Quote
http://www.lazarus.freepascal.org/index.php/topic,11695.msg58964.html#msg58964

Kindly help me, please  :'( .
Lazarus 1.2.4 / Win 32 / THAILAND

 

TinyPortal © 2005-2018