Combo box inside GridView

10 posts, 0 answers
  1. yaqub
    yaqub avatar
    6 posts
    Member since:
    Mar 2009

    Posted 11 Aug 2009 Link to this post

    Hi,

    I need your help to use GridViewComboBoxColumn inside RadGridView.

    1:     Please guide me how can i access the GridViewComboBoxColumn in RadGridView_CellFormatting Event.

    2:    How can i get the GridViewComboBoxColumn when processing each row of the grid?

    Thanks.
  2. lkeel
    lkeel avatar
    115 posts
    Member since:
    Jul 2012

    Posted 11 Aug 2009 Link to this post

    I have recently had to do just this, so here is what I found.  Please note I am not a Telerik team member so this may not be the absolute best solution, but it is what I got to work for me...

    In answer to #1:
    (NOTE: In this case the unique name for the column that has my checkbox is "enabled")
    if (this.grid.Columns[e.CellElement.ColumnIndex].UniqueName == "enabled")
    {
    ((RadCheckBoxEditorElement) e.CellElement.Children[0]).Checked = Telerik.WinControls.Enumerations.ToggleState.On;
    }


    In answer to #2:
    If you are just trying to find the rows that are checked, then here is a linq statement that I wrote:
    (NOTE: In this case the unique name for the column that has my checkbox is "enabled")
    List<GridViewDataRowInfo> selectedRows = new List<GridViewDataRowInfo>(from selRow in this.grid.Rows
                                                                                       where ((RadCheckBoxEditorElement)selRow.Cells["enabled"].CellElement.Children[0]).CheckState == Telerik.WinControls.Enumerations.ToggleState.On
                                                                                       orderby this.grid.Rows.IndexOf(selRow)
                                                                                       select selRow );


    If you are trying to loop through all the rows then:
    foreach (GridViewRowInfo row in this.grid.Rows)
    {
                       checked = ((RadCheckBoxEditorElement) row.Cells["enabled"].CellElement.Children[0].CheckState == Telerik.WinControls.Enumerations.ToggleState.On;
    }


    Hope this helps...
    Lee
  3. Victor
    Admin
    Victor avatar
    1358 posts

    Posted 14 Aug 2009 Link to this post

    Hello Yaqub,

    Thank you for writing. You can check in CellFormatting if the column that the arguments point to is a GridViewComboBox column. Here is how the event handler for CellFormatting should look like:

    void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)  
    {  
        if (this.radGridView1.Columns[e.CellElement.ColumnIndex] is GridViewComboBoxColumn)  
        {  
            // Do necessarry tasks.  
        }  

    When iterating over the rows you can do this:

    foreach(GridViewRowInfo row in this.radGridView1.Rows)  
    {  
        // Loop through the cells only if you do not know the indices of your combo box columns.  
        foreach (GridViewCellInfo cell in row.Cells)  
        {  
            if (this.radGridView1.Columns[cell.ColumnInfo.Index] is GridViewComboBoxColumn)  
            {   
                // Do necessary tasks.  
            }  
        }  

    Write again if you have other questions.

    Greetings,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. yaqub
    yaqub avatar
    6 posts
    Member since:
    Mar 2009

    Posted 14 Aug 2009 Link to this post

    Hi,
    This is helpful!
    Thanks.
  5. SachinC
    SachinC avatar
    23 posts
    Member since:
    Sep 2010

    Posted 19 Sep 2010 Link to this post

    HI,

    i have added combobxocolumn in raggridview programatically and given a datasource to it.

    Private Sub AddUserSignOffColumn()
      
    Dim ddlUserSignoffColumn As New GridViewComboBoxColumn
      
    With ddlUserSignoffColumn
      
    .HeaderText = "User SignOff"
      
    .DisplayMember = "UserName"
      
    .ValueMember = "UserID"
      
    .FieldName = "ChecklistSignoffUser"
      
    .Name = "ChecklistSignoffUser"
      
    .Width = 110
      
    .AllowFiltering = False
      
    .AllowGroup = False
      
    .AllowHide = False
      
    .AllowResize = False
      
    .AllowSort = False
      
    .DropDownStyle = RadDropDownStyle.DropDownList
      
    .AutoCompleteMode = AutoCompleteMode.SuggestAppend
      
    ddlUserSignoffColumn.DataSource = dtUsers
      
    End With
      
    gridViewHome.MasterTemplate.Columns.Insert(11, ddlUserSignoffColumn)
      
    End Sub

    when the grid view is displayed currently its showing blank by default. when i click on comboboxcell then dropdownlist is displayed.
    what i want to do is that,
    if the "ChecklistSignoffUser" value is null in database i want to display value as "Select User" from datasource and if the
    id is present then by defult the username must be displayed.

    how to change the selected value of comboboxcolum  in cellformating event?

    Thanks
  6. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 22 Sep 2010 Link to this post

    Hi Sachin,

    To achieve the described functionality, you should use combo-box column's NullValue property:
    Dim ddlUserSignoffColumn As New GridViewComboBoxColumn   
    ddlUserSignoffColumn.NullValue = "Select User"

    I hope this helps. Let me know if you have other questions.

    Sincerely yours,
    Martin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Randa
    Randa avatar
    14 posts
    Member since:
    Jul 2011

    Posted 19 Dec 2011 Link to this post

    What if I want to display the selected Value of a RadDropDownList in a GridviewComboBoxColumn?
  8. Ivan Petrov
    Admin
    Ivan Petrov avatar
    705 posts

    Posted 22 Dec 2011 Link to this post

    Hello Randa,

    Thank you for writing.

    Can you please explain what you want to achieve in greater detail as I do not fully understand your requirement. In addition, add the version of the control you are using as this thread is very old and it is discussing a very old version.

    I am looking forward to your reply.

    All the best,
    Ivan Petrov
    the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
  9. Babison
    Babison avatar
    1 posts
    Member since:
    Jan 2012

    Posted 08 Jan 2012 Link to this post

    i hav a radmulticolumncombobox in datagrid and i want filtering in that case how i can do that???
  10. Ivan Petrov
    Admin
    Ivan Petrov avatar
    705 posts

    Posted 11 Jan 2012 Link to this post

    Hello Babison,

    Thank you for writing.

    Currently the RadMultiColumnComboBox editor in the RadGridView does not have filtering functionality available. We will consider it when we plan our future releases if other users ask for it.

    Should you need other help, feel free to write back.

    Greetings,
    Ivan Petrov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top