Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Tell if an item is selected in flygrid...

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

Tell if an item is selected in flygrid...
Link Posted: 03-Aug-2005 12:15
I need to tell if anything has been selected in a flygrid, the below code works as long as something has been select, but if nothing has been selected it gives an error:

"An unhandled exception of type 'System.NullReferenceException' occurred in ICAS.exe

Additional information: Object reference not set to an instance of an object."

my code is:


        If Me.flygrid1.Selected.Items.Count = 0 Then
            msgbox "something is selected"
        Else
            msgbox "nothing selected"
        End If


Could you please help.

Thanks in advance

Simon
Link Posted: 03-Aug-2005 13:04
To handle multiple nodes/rows selection changes use FlyGrid.SelectionChanging/SelectionChanged events (in the case FlyGrid.Options.MultiSelect = true)

To handle single node selection changes use FlyGrid.NodeFocusChanging/NodeFocusChange events

To determine multiple nodes selection (and get array of selected nodes), use following code:

VB.Net
Dim selection as Node() = flyGrid.Rows.GetSelection
If (not selection is Nothing And selection.Length > 0) Then
  'flyGrid has selection
End If


To determine single selected/focused node
use following code:

If (Not flyGrid.Selected is Nothing) Then
  'flyGrid has selected node
End If