Combobox in cell

Feb 9, 2010 at 2:25 PM

Hi all

Sincerely hope someone will be able to help me. Just started using sourcegrid and so far I get the basic stuff. I am trying to create a combobox in a cell that contains a list of database tables extracted using the database schema. I created a method that creates different editors, so far the checkbox portion works fine but I can't get the combobox to show or to dropdown when I click a cell. I do see the appropriate text but no button to open the combobox.

Here is the creation code. The portion in Blue is the code that troubles me.

Public Sub InsertEditorCell(ByRef aGrid As SourceGrid.Grid, ByVal Row As Integer, ByVal Col As Integer, _
                                ByVal TypeCell As CellEditorType, Optional ByRef CellContentList As List(Of String) = Nothing, _
                                Optional ByVal SelectedItem As Integer = 0)
        Try
            Select Case TypeCell
                Case CellEditorType.cetNone
                    aGrid(Row, Col) = New SourceGrid.Cells.Cell()
                Case CellEditorType.cetCheckBox
                    aGrid(Row, Col) = New SourceGrid.Cells.CheckBox(Nothing, False)
                Case CellEditorType.cetCombox
                    Dim EditorCombo As SourceGrid.Cells.Editors.ComboBox = _
                               New SourceGrid.Cells.Editors.ComboBox(GetType(String), CellContentList, True)
                    EditorCombo.StandardValues = CellContentList
                    EditorCombo.EnableEdit = True
                    EditorCombo.EditableMode = EditableMode.Focus And EditableMode.AnyKey And EditableMode.SingleClick
                    EditorCombo.Control.DropDownHeight = 50
                    EditorCombo.Control.DropDownStyle = ComboBoxStyle.DropDownList
                    aGrid(Row, Col) = New SourceGrid.Cells.Cell(CellContentList(SelectedItem), EditorCombo)
                    aGrid(Row, Col).Editor = EditorCombo
            End Select
        Finally
            aGrid.AutoSizeCells()
        End Try
    End Sub

What am I doing wrong

 

Feb 9, 2010 at 2:42 PM
Edited Feb 9, 2010 at 6:02 PM

Hi all again

 

Well I am either brillant or an absolute moron but I tried this and it works great( Ireplace the portion in blue above by the following code)

Dim aCombo As ComboBox = New ComboBox()
For Each s As String In CellContentList
    aCombo.Items.Add(s)
Next

aCombo.SelectedIndex = SelectedItem

aGrid.Rows.Insert(Row)
Dim EditorControl As SourceGrid.LinkedControlValue = New SourceGrid.LinkedControlValue(aCombo, CellPos)
aGrid.LinkedControls.Add(EditorControl)

 

NOTE: this does work with version 4.20 but not with 4.22 weird???????

Coordinator
Feb 10, 2010 at 7:45 AM
Edited Feb 10, 2010 at 12:49 PM
caouellet wrote:

Hi all again

 

Well I am either brillant or an absolute moron but I tried this and it works great( Ireplace the portion in blue above by the following code)

Dim aCombo As ComboBox = New ComboBox()
For Each s As String In CellContentList
    aCombo.Items.Add(s)
Next

aCombo.SelectedIndex = SelectedItem

aGrid.Rows.Insert(Row)
Dim EditorControl As SourceGrid.LinkedControlValue = New SourceGrid.LinkedControlValue(aCombo, CellPos)
aGrid.LinkedControls.Add(EditorControl)

 

NOTE: this does work with version 4.20 but not with 4.22 weird???????

If it is a bug, we should fix that then.

 

Could you please create a separate stand-alone project to demonstrate that with 4.22 this does not work?