gridViewComboBoxColumn1 DisplayMember for CheckBoxColumn

3 posts, 1 answers
  1. Tommy
    Tommy avatar
    2 posts
    Member since:
    Aug 2015

    Posted 16 Oct 2015 Link to this post

    I'm using C#
    Telerik UI for Winforms Q3 2015
    Using a RadForm.
    I have a radgridview. 
    I'm trying to get a Boolean Column to show as a Checkbox column.
                gridViewComboBoxColumn1.DataSource = this.propertiesBindingSource;
                gridViewComboBoxColumn1.DataType = typeof(bool);
                gridViewComboBoxColumn1.DisplayMember = "lease_up";
                gridViewComboBoxColumn1.EnableExpressionEditor = false;
                gridViewComboBoxColumn1.FieldName = "propertynumber";
                gridViewComboBoxColumn1.HeaderText = "column2";
                gridViewComboBoxColumn1.Name = "column2";
                gridViewComboBoxColumn1.ValueMember = "property_number";
    This returns True or False as it should.

    I want to use the DisplayMember Value for a CheckBox
                gridViewCheckBoxColumn2.EnableExpressionEditor = false;
                gridViewCheckBoxColumn2.Expression = "LeaseUp ";
                gridViewCheckBoxColumn2.FieldName = "LeaseUp2";
                gridViewCheckBoxColumn2.HeaderText = "Lease Up 2";
                gridViewCheckBoxColumn2.IsAutoGenerated = true;
                gridViewCheckBoxColumn2.MinWidth = 20;
                gridViewCheckBoxColumn2.Name = "LeaseUp2";
                gridViewCheckBoxColumn2.ReadOnly = true;
                gridViewCheckBoxColumn2.Width = 80;

    To Make sure what value was being passed I added the TextBox Column Below for testing
                gridViewTextBoxColumn2.EnableExpressionEditor = false;
                gridViewTextBoxColumn2.Expression = "column2 ";
                gridViewTextBoxColumn2.HeaderText = "column1";
                gridViewTextBoxColumn2.Name = "column1";
                gridViewTextBoxColumn2.ReadOnly = true;
    The Value returned by the Expression is the ValueMember (property_number)
    and not the DisplayMember (lease_up)
    What do I need to put in the Expression of either the TextboxColumn or
    CheckBoxColumn to return gridViewComboBoxColumn1.DisplayMember (lease_up Boolean value)?
    Any help will be greatly appreciated.

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4168 posts

    Posted 20 Oct 2015 Link to this post

    Hello Tommy,

    Thank you for writing.
    I am not sure what is the complete scenario on your end, but have in mind that GridViewComboBoxColumn stores in the cell's Value this column/property of the DataSource that is specified as GridViewComboBoxColumn.ValueMember. The DisplayMember property is used only to display the relevant text in the grid cells. In order to get the text (DisplayMember) by the cell value, feel free to use the GridViewComboBoxColumn.GetLookupValue(object cellValue) method.

    If it does not suit your scenario, please specify in details what is the exact requirement that you are trying to achieve. Feel free to open a support ticket where you can provide a sample project replicating the undesired result. Thus, we would be able to investigate the precise case and assist you further. Thank you in advance.
    I hope this information helps. Should you have further questions I would be glad to help.
    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 Feedback Portal and vote to affect the priority of the items
  3. Tommy
    Tommy avatar
    2 posts
    Member since:
    Aug 2015

    Posted 21 Oct 2015 Link to this post


    Thank you for the reply. It just took me a while to figure out where and how to use GetLookupValue.

    This is what I ended up with.

    foreach (Telerik.WinControls.UI.GridViewRowInfo rowInfo in radGridView1.Rows)
     foreach (Telerik.WinControls.UI.GridViewCellInfo cellInfo in rowInfo.Cells)
      if (cellInfo.ColumnInfo.Name == "PropertyNumber")
       object value = rowInfo.Cells[0].Value;
       object displayMember = ((Telerik.WinControls.UI.GridViewComboBoxColumn)radGridView1.Columns[2]).GetLookupValue(value);
       rowInfo.Cells["LeaseUp2"].Value = Convert.ToBoolean(displayMember);

    Thanks again.


Back to Top