Jump to content


Photo

How to set ItemIndex of each row in TNxComboBoxColumn?

tnextgrid inplaceedit

  • Please log in to reply
4 replies to this topic

#1 Peter5

Peter5
  • Members
  • 3 posts

Posted 15 November 2017 - 02:36 PM

I have a TNextGrid with various columns, one of which is a TNxComboBoxColumn.

 

This column is populated at runtime with a list of possible values:

 

nxRightToWorkDoc.Items.Clear;
nxRightToWorkDoc.Items.AddStrings(stringlistERTW);

 

Next step is to populate the TNextGrid with the results of a database query using a "while not tbl.EOF do" loop.

 

The problem I'm having is that I do not know how to directly set the .ItemIndex on the TNxComboBoxColumn column for every row in the dataset.

 

I have found this proposed solution:

 

TNxComboBox(nxRightToWorkDocNew.Columns[nxRightToWorkDocNew.Position].Editor).ItemIndex := <value>

 

However, I don't understand how the row is identified in the above piece of code.

 

I would appreciate it if anyone can point me in the right direction :)
 



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 7,856 posts
  • Gender:Male

Posted 15 November 2017 - 03:09 PM

Hi,

For this purpose I suggest using TNxListColumn instead. This column keep as cell value - indexes. So you need to add items as you do in ComboBoxColumn, but then inside cell you set:
 
MyGrid.Cell[x, y].AsInteger := MyDesiredItemIndex;
Hope this helps :)
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Members Section: bms.bergsoft.net
Articles and Tutorials: dn.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.

#3 Peter5

Peter5
  • Members
  • 3 posts

Posted 15 November 2017 - 04:35 PM

Thanks, each cell now displays the correct value. :)

 

However, when I click on a cell in runtime it doesn't provide the list of dropped down values to select from, like TNxComboBoxColumn does. Is this not possible, or if it is, how can I enable this behaviour?

 

I set AutoDropDown := True but it has no effect.



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 7,856 posts
  • Gender:Male

Posted 15 November 2017 - 05:42 PM

Hi,

For this purpose you need to set coEditing flag to True in Options property of Column. In v6 is Editing Boolean property.

Hope this helps.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Members Section: bms.bergsoft.net
Articles and Tutorials: dn.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.

#5 Peter5

Peter5
  • Members
  • 3 posts

Posted 15 November 2017 - 06:00 PM

Fantastic, thank you for your help! :)







1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users