15 Answers, 1 is accepted
Thank you for contacting us.
You are able to get the value of a RadComboBoxColumn's cell using the standard approach for accessing cells described in this article. In case I have misunderstood your question, please provide further details about your scenario.
Greetings,
Boryana
the Telerik team

I have a RadGridView with a GridViewComboBoxColumn "Operation".
I have an object (objID, objCode,....) that I am using as the data source for this GridViewComboBoxColumn
The DisplayMember = "objCode" while the ValueMember = "ObjID"
I would like to find out how to retrieve the "objCode" value currently chosen in the GridViewComboBoxColumn.
Thanks!
Thank you for contacting Telerik Support.
In order to get the display member value for GridComboBoxCellElement you may use the following approach:
public
Form1()
{
InitializeComponent();
List<CustomObject> list =
new
List<CustomObject>();
for
(
int
i = 0; i < 10; i++)
{
list.Add(
new
CustomObject(i,
"Code"
+ i));
}
GridViewComboBoxColumn comboCol =
new
GridViewComboBoxColumn(
"Combo column"
);
comboCol.DataSource = list;
comboCol.ValueMember =
"ID"
;
comboCol.DisplayMember =
"Code"
;
this
.radGridView1.Columns.Add(comboCol);
this
.radGridView1.CellClick += radGridView1_CellClick;
}
private
void
radGridView1_CellClick(
object
sender, GridViewCellEventArgs e)
{
GridComboBoxCellElement cell = sender
as
GridComboBoxCellElement;
if
(e.Column
is
GridViewComboBoxColumn && cell !=
null
)
{
if
(!
string
.IsNullOrEmpty(cell.Text))
{
//CustomObject.Code
MessageBox.Show(cell.Text);
}
}
}
public
class
CustomObject
{
public
int
ID {
get
;
set
; }
public
string
Code {
get
;
set
; }
public
CustomObject(
int
iD,
string
code)
{
this
.ID = iD;
this
.Code = code;
}
}
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

I'm trying to get the GridComboBoxCellElement within CellValidating handler. Is this possible?
When I try to use the GridDataCellElement Text Property (from grid.CurrentCell) the value is empty string at this time.
I have tested the solution in Cellclick.
I can see that I could probably set the cell text in either CellClick (if clicked) or possibly CellBeginEdit and save to use when required.
However, it would be ideal to retrieve the GridComboBoxCellElement in RowValidating/CellValidating, if possible.
Tips are appreciated!
Thank you for writing back.
You can obtain an empty value in the CellValidating event when you are in edit mode in the New row. However, you can access the string value via the active editor element. Otherwise, when the grid is not in edit mode you can get the string value from the current cell's text. Here is a sample code snippet:
private
void
radGridView1_CellValidating(
object
sender, CellValidatingEventArgs e)
{
RadGridView grid = sender
as
RadGridView;
if
(grid.EditorManager.ActiveEditor !=
null
)
//edit mode
{
RadDropDownListEditor editor = grid.EditorManager.ActiveEditor
as
RadDropDownListEditor;
if
(editor !=
null
)
{
RadDropDownListEditorElement element = editor.EditorElement
as
RadDropDownListEditorElement;
MessageBox.Show(element.Text);
}
}
else
{
MessageBox.Show(grid.CurrentCell.Text);
}
}
Please do not hesitate to contact us if you have any additional questions.
Regards,
Desislava
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

Is there anyway to retrieve the DisplayMember value of GridViewComboBoxColumn in the CellEndEdit ? Thanks.
Thank you for writing.
In the CellEndEdit event you can directly get the CurrentCell.Text property:
private
void
radGridView1_CellEndEdit(
object
sender, GridViewCellEventArgs e)
{
GridViewEditManager editManager = sender
as
GridViewEditManager;
if
(editManager !=
null
)
{
Console.WriteLine(editManager.GridViewElement.CurrentCell.Text);
}
}
Note that the GridViewComboBoxColumn offers the GetLookupValue(object cellValue) method which returns the lookup value corresponding to the specified cell value.
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Thanks.
Thank you for writing back.
If you set the GridViewComboBoxColumn.AutoCompleteMode property to AutoCompleteMode.Append, when typing in the editable part of the RadDropDownListEditor, you will obtain appended the first suggestion. As a result, the selected value will be updated and when the CellEndEdit event is fired, you will see the editManager.GridViewElement.CurrentCell.Text. However, if you type a string that does not match any of the available items, the cell value will be set to null. This behavior is expected.
If you need to allow users to enter custom values, please have a look at our Allow end-users to add items to DropDownListEditor help article.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Hi Dess-
Can I make a feature request?
Can we have a the GridView control updated to include something like this: row.Cells["myColumn"].DisplayedValue along side row.Cells["myColumn"].Value. They would both be the same except when you the column is a gridViewComboBoxColumn.
I regularly need to use data from a GridView that is bound to a datasource. Adding a DisplayedValue string to the object list would make my job a whole lot easier.
Thank you for your consideration.
-Scott
Thank you for writing.
You can get the displayed text very easily by the GetLookupValue method of the GridViewComboBoxColumn. It is just necessary to pass the cell's value. Here is a sample code snippet:
private
void
radGridView1_CellClick(
object
sender, GridViewCellEventArgs e)
{
GridViewComboBoxColumn comboColumn = e.Column
as
GridViewComboBoxColumn;
if
(comboColumn!=
null
)
{
object
cellValue = e.Row.Cells[e.Column.Name].Value;
Console.WriteLine(comboColumn.GetLookupValue(cellValue));
}
}
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik


Hi all team,
I curently have a radGridview populate by a datatable.
Once populated, I add a GridViewComboBoxColumn also populated by an other DataTable :
GridViewComboBoxColumn relaying_stuff = new GridViewComboBoxColumn();
relaying_stuff.Name = "Relaying Stuff";
relaying_stuff.HeaderText = "Relaying Stuff";
relaying_stuff.DataSource = stuffSource;
relaying_stuff.ValueMember = "id_stuff";
relaying_stuff.DisplayMember = "name";
this.radGridView1.Columns.Add(relaying_stuff)
Only this ComboBoxColumn can be edited in the gridview.
What I do not succeed in performing is on "ComboBoxColumn change value of the dropdown list" event, to get back the ValueMember "id_stuff" selected.
I have been trying with GetLookupValue function without any success.
A piece of help would be highly appreciated..
Thanks in advance.
Jeff

I found the solution, that was so easy :
On ValueChanged event
radGridView1.ActiveEditor.Value
I am glad that you have found a suitable solution for your case. Please have in mind that the ActiveEditor.Value property will give you the selected value while the editor is active and the value is still not committed to the cell. Once the editor is closed and the value is stored in the cell, you can use the directly the cell's Value for the ValueMember and the previously suggested GridViewComboBoxColumn.GetLookupValue method for the DisplayMember.
If you have any additional questions, please let me know.
Dess
Progress Telerik