Jump to content


Photo

How to get selected object from combobox column


  • Please log in to reply
2 replies to this topic

#1 juppstrunk

juppstrunk
  • Members
  • 4 posts

Posted 11 April 2014 - 12:33 PM

Hello,

I want to use a NextGrid with two columns, the first being a simple NxTextColumn, the second a NxComboBoxColumn.
The comboboxes shall contain (along with the label) objects, just like you can do with standard comboboxes.
Each row shall have an identical combox.

So I initalize it like this:
TNxComboBoxColumn(myGrid.Columns[1]).Items.AddObject(someLabel, someObject)

I expected that I can then get the selected object for each row, but I can't figure out how.

I tried with
myGrid.Cell[1, row].ObjectReference
but this always returns nil.

I tried to use the ItemIndex
TNxComboBox(myGrid.Cell[1, row]).ItemIndex
but this returns weird numbers.

So I am apparently doing something wrong. Can you give me any hints?

Thanks,
JS

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 12 April 2014 - 07:54 AM

Hi,

I suggest using TNxListColumn and then access to the object in Items array by reading Cell's value. Cell's value is a integer (instead of string in TNxComboBoxColumn) and represent ItemIndex.

MyObj := MyListColumn.Items.Objects[NextGrid1.Cell[MyListColumn.Index, aRow].AsInteger;

Best regards
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.

#3 juppstrunk

juppstrunk
  • Members
  • 4 posts

Posted 14 April 2014 - 12:17 PM

Thanks a lot Boki, this works!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users