Jump to content


Photo

Filling NxComboBoxColumn with different values for each row at runtime


  • Please log in to reply
1 reply to this topic

#1 tumbleweed

tumbleweed
  • Members
  • 4 posts

Posted 18 August 2015 - 11:15 PM

I just started using the NxGrid control and there's something fundamental I'm not understanding.

 

I have a NxGrid with two columns: a NxComboBoxColumn and a NxListColumn. I need each row that I add to have a ComboBox with different entries that aren't fixed (they come from some StringList variables).

For example I want the ComboBoxColumn for row(0) to contain "Fred", "Tom", and "Bob", and row(1) to contain "Mary", "Sally" "Jill" and "Susie".

 

Right now I have something like

 

NextGrid1.AddRow; // Add single row
NextGrid1.SelectLastRow();

// add the strings from this row's stringlist to the combobox for this row
for Index := 0 to MyStringList.Count - 1 do
begin
    with NextGrid1.Columns[1] as TNxComboBoxColumn do
    begin
       Items.Add(MyStringList.Strings[Index]);
    end;
end;

 

where I change the contents of MyStringList each time before adding the next row.

When I do that, the combo box in each row ends up containing the same data... whatever stringlist I add last.

 



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 19 August 2015 - 01:28 AM

Hi,

 

You probably want that when you start editing to change values inside ComboBox?

 

For this, I suggest that you use DoApplyEditText event for this, and then populate InplaceEdit directly there.

 

Cast NextGrid1.InplaceEdit as TNxComboBox and access Items property as normal.

 

Example:

 

procedure TForm1.NextGrid1ApplyEditText(Sender: TObject; ACol, ARow: Integer;
  var Value: WideString);
begin
  with NextGrid1.InplaceEdit as TNxComboBox do
  begin
    Items.Clear;
    if ARow = 2 then
    begin
      Items.Add('a)For row 2');
      Items.Add('b)For row 2')
    end else
    begin
      Items.Add('a)For other rows');
      Items.Add('b)For other rows too')
    end;
  end;
end;

boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users