Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Finding the selected index in NineRays.Windows.Forms.Grids.DropDownListColumn

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Finding the selected index in NineRays.Windows.Forms.Grids.DropDownListColumn
Link Posted: 16-Mar-2012 06:36
How to get the selected index of an item which uses DropDownListColumn? we do not see any property called selected index for the class dropdownlistcolumn.

we are using FlyGrid.Net version
Link Posted: 16-Mar-2012 16:02
Could you explain for that purpose you need to use selected index?
Link Posted: 16-Mar-2012 21:24
So, for a column in the node, we changed editor style to dropdown so it can show few items; one of which could be selected by the user. We were able to get the selected item as a string using GetCellValue but we need the index number of the selected item because the items in the dropdown could be same but are different from each other. See below example.

the dropdown shows the items like


The items under the dropdown are indented so they relate to their particular statements i.e., Statement1, Statement2, etc.

When user selects IBM under Statement2, we get the string IBM but we do not know if it is of Statement1 or 2 because the IBM present under Statement1 and 2. That is why we are looking for an index number of the selected item.

Hope this gives clear picture. Sorry for not being so clear in the initial post.
Link Posted: 17-Mar-2012 06:44
Thanks for the explanation.
You can use following sample to get the index of selected item. This code you can use in the NodeCellChange or NodeCellChanging events (get the IDropDownListService and get the selected index):
Private Sub dgParams_NodeCellChange(ByVal sender As Object, ByVal node As NineRays.Windows.Forms.Data.NodeBase, ByVal index As Integer, ByVal value As Object) Handles dgParams.NodeCellChange
    If (index = 0) Then
      'cast FlyGrid as IServiceProvider
      Dim sp As IServiceProvider = CType(Me.dgParams, IServiceProvider)
      ' get a IDropDownListService instance
      Dim idls As NineRays.Windows.Forms.Grids.IDropDownListService = _
      If (Not idls Is Nothing) Then 'if it supported - receive currently selected index
        Dim selectedIndex As Integer = idls.SelectedIndex
        'output to diagnostics console    
        System.Diagnostics.Debug.WriteLine("Selected Index is " + selectedIndex.ToString())
        'here place your code....
      End If
    End If
  End Sub