Home Forums WinForms controls Xceed Grid for WinForms Populating GridComboBox on activate

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

    I have a column that uses a GridComboBox for its CellEditor. When the user selects the cell, I want to execute some code that populates the combo based upon the row’s ValueMember and selects the appropriate value. I’m confused about how to do this. Important to note that each row could have a different list of items in the combo.

    Thanks for any advice.

    Imported from legacy forums. Posted by EasyRhino (had 2798 views)

    User (Old forums)
    Member
    Post count: 23064

    You need to subscribe to the cell’s Entering edit event and then in this event load the combo.
    Here is what I have done. Hope this helps.

    Private Sub AddEvents()
    Dim tempCell As Xceed.Grid.Cell

    grdGrid.BeginInit()

    For Each tempCell In grdGrid.DataRowTemplate.Cells

    AddHandler tempCell.EnteringEdit, AddressOf Me.cell_EnteringEdit

    Next

    grdGrid.EndInit()
    End Sub

    Private Sub grdGrid_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdGrid.CurrentCellChanged

    If Not grdGrid.CurrentCell Is Nothing Then
    grdGrid.CurrentCell.EnterEdit()
    End If

    End Sub

    Private Sub cell_EnteringEdit(ByVal sender As Object, ByVal e As Xceed.Grid.EnteringEditEventArgs)

    ‘Fill combo with correct data
    LoadCombo(mcboValue1)

    End Sub

    Imported from legacy forums. Posted by Jeff W (had 331 views)

    User (Old forums)
    Member
    Post count: 23064

    Here’s how I did it:

    private void DataRowTemplate_BeginningEdit(object sender, CancelEventArgs e)
    {
    GridComboBox gcb = ((GridComboBox)((CellRow)sender).Cells[3].CellEditor.Control);
    gcb.Items.Clear();
    DataSet ds = ws.GetMilestones(Convert.ToInt32(((CellRow)sender).Cells[5].Value.ToString().Split(‘%’)[1]));

    gcb.BeginUpdate();

    foreach(System.Data.DataRow dr in ds.Tables[0].Rows)
    {
    gcb.Items.Add(dr[2].ToString());
    }

    gcb.EndUpdate();
    gcb.SelectedIndex = gcb.FindString(((CellRow)sender).Cells[3].Value.ToString());
    }

    Imported from legacy forums. Posted by EasyRhino (had 3982 views)

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