Home Forums WinForms controls Xceed Grid for WinForms selected item in ComboBox/WinComboBox

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14809 |

    Hello, ive got the next problem… i want to insert a coomboBiox in a Xceed Grid.
    All works fine, but if the property SelectedItem doesnt work and i cant select one of the items in the grid when this grid its displayed for first time.

    Where are us wrong?

    Imports Xceed.Grid
    Imports Xceed.Editors
    Imports Xceed.Grid.Editors
    Imports Xceed.Grid.Viewers

    Public Class Form1

    Private SuggestedWorker As Column

    Private CoordinatorNameColumn As ColumnInfo
    Private selc As ComboBoxEditor
    Private sel As WinComboBox
    Dim row As DataRow
    Private item As ComboBoxItem
    Private selectedItem As ComboBoxItem

    Public Sub New()
    Xceed.Editors.Licenser.LicenseKey = “EDN20-???……………”
    Xceed.Grid.Licenser.LicenseKey = “GRD30-??……………..”
    ‘ This call is required by the Windows Form Designer.
    InitializeComponent()
    ‘ Add any initialization after the InitializeComponent() call.
    InitializeSelectionGridControl()

    End Sub

    Private Sub InitializeSelectionGridControl()
    Dim coordinators As New List(Of String)()
    SuggestedWorker = New Column(“Suggested Worker”, GetType(WinComboBox))
    SuggestedWorker.Width = 100
    Me.CoordinatorGridControl.Columns.Add(SuggestedWorker)

    CoordinatorNameColumn = New ColumnInfo(“Name”, GetType(String))

    coordinators.Add(“luis”)
    coordinators.Add(“pedro”)
    coordinators.Add(“pedro3”)
    coordinators.Add(“pedro4”)

    Me.sel = New WinComboBox()
    Me.sel.Columns.Add(CoordinatorNameColumn)
    Me.sel.MaxDropDownItems = 5
    Me.sel.IntegralHeight = True

    For Each coor As String In coordinators
    item = New ComboBoxItem({coor})
    Me.sel.Items.Add(item)
    Next
    Me.sel.SelectedItem = Me.sel.Items(0)

    Dim a As New ComboBoxViewer(sel)

    row = Me.CoordinatorGridControl.DataRows.AddNew()
    Me.selc = New ComboBoxEditor(sel)
    row.Cells(“Suggested Worker”).CellEditorManager = Me.selc
    row.Cells(“Suggested Worker”).CellEditorDisplayConditions = CellEditorDisplayConditions.Always
    row.EndEdit()
    End Sub
    End Class

    Imported from legacy forums. Posted by Jacobo (had 2114 views)

    User (Old forums)
    Member
    Post count: 23064

    This will work only on the specific editor, not on the template. When you set the CellEditorManager, this is only a template that is used to create each cells of the column. So to get the ComboBox to display a specific item, you need to get to the specific editor in that cell, which is available only once it is create, that is, when the grid is fill with data.

    To get to the specific editor of a cell, you need to first activate the editor in the cell.

    e.g. :

    gridControl1.DataRows[ 0 ].Cells[ 0 ].EnterEdit();

    Then you can use the SelectedItem property to display the item you want.

    e.g. :

    ( ( WinComboBox )gridControl1.DataRows[ 0 ].Cells[ 0 ].CellEditorControl).SelectedItem = ( ( WinComboBox )gridControl1.DataRows[ 0 ].Cells[ 0 ].CellEditorControl).Items[ 2 ];

    Note that doing this may put much overhead to the loading of the grid, depending on how many rows there is in the grid.

    Imported from legacy forums. Posted by André (had 3153 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.