-
TerryStringer said 1 year, 2 months ago:
I’ve read the Main Application in the documentation but still am totally lost on how to add a simple drop-down list box to a cell in my Flexgrid. I’m using the grid in unbound mode. So, for example, how can I add a drop-down listbox on cell GridTable(1,1)? The list box contains:
Item 1
Item 2
Item 3That’s it. The grid is non-editable. I just need the user to select one of the three items.
I’m building this in Code-behind in VB.
Thank you!
| # -
Hi Terry,
You may implement it this way, in PrepareCellForEdit event:
Private Sub GridTable_PrepareCellForEdit(ByVal sender As Object, ByVal e As C1.WPF.FlexGrid.CellEditEventArgs) Handles GridTable.PrepareCellForEdit If e.Row = 1 AndAlso e.Column = 1 Then Dim _border As Border = DirectCast(DirectCast(e.Editor, System.Windows.FrameworkElement), System.Windows.Controls.Border) Dim cmb As C1.WPF.FlexGrid.C1FlexComboBox = CType(_border.Child, C1.WPF.FlexGrid.C1FlexComboBox) cmb.DropDownItems = New String() {"Item 1″, "Item 2″, "Item 3″} cmb.IsEditable = False End If End SubCheers,
Anupam.| # -
I just figured another way to implement this. Cellfactory
Here’s the customized CellFactory :
Class MyCellFactory Inherits C1.WPF.FlexGrid.CellFactory Public Overrides Function CreateCellEditor(ByVal grid As C1.WPF.FlexGrid.C1FlexGrid, ByVal cellType As C1.WPF.FlexGrid.CellType, ByVal range As C1.WPF.FlexGrid.CellRange) As System.Windows.FrameworkElement If range.Row = 0 And range.Column = 0 Then Dim _border As Border = CType(MyBase.CreateCellEditor(grid, cellType, range), Border) Dim cmb As C1.WPF.FlexGrid.C1FlexComboBox = CType(_border.Child, C1.WPF.FlexGrid.C1FlexComboBox) cmb.DropDownItems = New String() {"Item 1″, "Item 2″, "Item 3″} cmb.IsEditable = False Return CType(_border, FrameworkElement) Else Return MyBase.CreateCellEditor(grid, cellType, range) End If End Function End ClassAnd then, assign this to GridTable’s CellFactory.
GridTable.CellFactory = New MyCellFactory
Cheers,
Anupam.| #
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.

