This is a migrated thread and some comments may be shown as answers.

gridViewComboBoxColumn1 DisplayMember for CheckBoxColumn

2 Answers 56 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tommy
Top achievements
Rank 1
Tommy asked on 16 Oct 2015, 07:29 PM

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.
Thanks,

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Oct 2015, 03:08 PM
Hello Tommy,

Thank you for writing.
 
I am not sure what is the complete scenario on your 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.
 
Regards,
Dess
Telerik
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
0
Tommy
Top achievements
Rank 1
answered on 21 Oct 2015, 04:06 PM

Dess,

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.

 

Tags
GridView
Asked by
Tommy
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Tommy
Top achievements
Rank 1
Share this question
or