Jump to content

Using grids


Recommended Posts

Hi,

 

I am trying to use a grid this way: I would like to be able to retreive a row ID when I click on a specific row to delete that row for example.

So far, here is what I got to create the ButtonColumn in the grid:

 


procedure TSpeakers.InitButtonColumn(ColumnName: String);
begin

  procedure W3ButtonColumnButtonClick(Sender: TObject);
  begin
    var i : integer;
    for i := 0 to Speakers.Count - 1 do
    begin
      var speaker :=  Speakers.Items[i] As TSpeaker;
      var button :=   TW3Button(Sender);
      if speaker.Name = TW3Button(Sender).Caption  then
      begin
         CurrentSpeaker :=  speaker;
         CurrentSpeakerLabel.Caption := CurrentSpeaker.Name;
      end
    end
  end;

  var ButtonColumn: TW3ButtonColumn;
  ButtonColumn := nil;
  ButtonColumn := TW3ButtonColumn.Create(SpeakerGrid as IW3ColumnsControl);
  ButtonColumn.Header.Caption := ColumnName;
  ButtonColumn.Width := 200;
  ButtonColumn.OnButtonClick := W3ButtonColumnButtonClick;

  SpeakerGrid.Columns.Add(ButtonColumn);

end;

And I create each row with the following:

 


procedure TSpeakers.AddRowToGrid(SpeakerName: String; SpeakerNumber: integer);
begin

  { Add 1 new row & set 1st cell in newly added row }
  SpeakerGrid.AddRow;
  SpeakerGrid.Cell[0, SpeakerGrid.LastAddedRow].Value := SpeakerName;

end;

So how can I specify a row ID when I create a row so that I can retreive it in the W3ButtonColumnButtonClick procedure in order to know what row I am processing?

 

Thanks

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...