I have tried using the example from customStylesGridForm, but for some reason it does not seem to produce the dropdown flygrid as it does in your example. I have posted the code below, and I am obviously doing something wrong.
_
Public Class CustomDropdownColumn
Inherits Column
Implements ISupportsCustomDropDown
Private _dropdownGrid As FlyGrid
Private lookupData As Object()
Private editedNode As NodeBase
Private dds As IDropDownService
Public Sub New(ByVal caption As String, ByVal lookupData As Object())
MyBase.New(caption)
_dropdownGrid = Nothing
editedNode = Nothing
dds = Nothing
Me.lookupData = lookupData
End Sub
Friend ReadOnly Property DropdownGrid() As FlyGrid
Get
If (_dropdownGrid Is Nothing) Then
_dropdownGrid = CreateDropdownGrid()
End If
Return _dropdownGrid
End Get
End Property
Protected Overrides Sub OnChanged(ByVal mode As NineRays.Windows.Forms.Grids.InvalidationMode, ByVal refreshMap As Boolean)
MyBase.OnChanged(mode, refreshMap)
If (Me.Current) Then
Me.BackColor = Color.AntiqueWhite
Else
Me.BackColor = SystemColors.Control
End If
End Sub
Public Overrides Property EditorStyle() As EditorStyle
Get
Return EditorStyle.DropDownResizable
End Get
Set(ByVal Value As EditorStyle)
End Set
End Property
Private Function CreateDropdownGrid() As FlyGrid
Dim grid As FlyGrid = New FlyGrid
Dim first As Column = New Column("User Name")
first.FitMode = ColumnFitMode.FitToText
Dim second As Column = New Column("Description")
second.FitMode = ColumnFitMode.FitToText
grid.Columns.Items.AddRange(New Column() {first, second})
grid.Options = grid.Options Or (GridOptions.RowSelect Or GridOptions.[ReadOnly] Or GridOptions.ShowFocusRectangle)
grid.Rows.DataSource = lookupData
grid.BackColor = SystemColors.Window
Dim width As Integer = 0
For i As Integer = 0 To grid.Columns.Items.Count - 1
width += grid.Columns.Items(i).Width + 2
Next i
Dim height As Integer = (grid.Columns.HeadersHeight + 1) + (grid.Rows.Items.Count * (grid.Rows.DefaultRowHeight + 1))
grid.Size = New Size(width, height)
AddHandler grid.KeyDown, AddressOf Me.grid_KeyDown
AddHandler grid.NodeDblClick, AddressOf Me.grid_NodeDblClick
Return grid
End Function
Private Sub SetSelection(ByVal data As String)
If (Not lookupData Is Nothing) Then
For i As Integer = 0 To lookupData.Length - 1
Dim row As System.String() = CType(lookupData(i), System.String())
Dim cell As String = row(0)
If (cell = data) Then
DropdownGrid.Selected = DropdownGrid.Rows.GetNodeFromRow(i)
Exit For
End If
Next i
End If
End Sub
Public Overridable Sub EditInDropDown(ByVal provider As IServiceProvider, ByVal node As NodeBase) Implements ISupportsCustomDropDown.EditInDropDown
dds = CType(provider.GetService(GetType(IDropDownService)), IDropDownService)
Dim grid As FlyGrid = CType(provider, FlyGrid)
If Not grid Is Nothing Then
DropdownGrid.Style = grid.Style
DropdownGrid.Stylist = grid.Stylist
End If
If Not dds Is Nothing Then
editedNode = node
SetSelection(MyBase.GetTextValue(node))
dds.DropDownControl(DropdownGrid, Me, True)
If (Not editedNode Is Nothing) AndAlso (Not DropdownGrid.Selected Is Nothing) Then
MyBase.SetValue(editedNode, DropdownGrid.Selected.GetCellValue(0))
End If
End If
End Sub
Private Sub grid_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
If (e.KeyCode = Keys.[Return]) OrElse (e.KeyCode = Keys.Escape) Then
If e.KeyCode = Keys.Escape Then
editedNode = Nothing
End If
dds.CloseDropDown()
End If
End Sub
Private Sub grid_NodeDblClick(ByVal sender As Object, ByVal node As NodeBase, ByVal col As Column)
dds.CloseDropDown()
End Sub
End Class
And this is the code on how I am trying to load the dropdown.
The attCode, attDesc, attIso, attPipe, attName are all just string values.
data = New Object() {attCode, attDesc, attIso, attPipe, attName, lookupData(1)(0)}
Me.FlyGrid1.Rows.Items.Add(New Node(data))
Once again thanks for your time and patience.
Simon