I'd like to add multi-select combobox column to my grid. I found an example of multi select combobox control in code library but I'm having trouble converting it to something that can be embedded in grid cell.
Can someone help ?
20 Answers, 1 is accepted
Basically you have to add GridViewMultiComboBoxColumn and set its DataSource, ValueMember, and DisplayMember properties. Here is a sample:
GridViewMultiComboBoxColumn multiComboColumn = new GridViewMultiComboBoxColumn("Items", ""); |
multiComboColumn.DataSource = items; |
multiComboColumn.ValueMember = "ID"; |
multiComboColumn.DisplayMember = "Name"; |
this.radGridView1.Columns.Add(multiComboColumn); |
If you have any other questions, don't hesitate to contact us back.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Thanks for answering but I think there is a misunderstanding. I didn't mean MultiComboBoxColumn but multi-select combobox column - a column which has combobox with the ability to select more than one entry (each entry has a checkbox next to it).
There is an example here http://www.telerik.com/community/code-library/winforms/combobox-and-listbox/radmultiselectcombobox.aspx
I'd like such functionality in grid column.
I apologize for this mistake. Now I understand what you want to achieve. Yes, you can use the code from this KB article as a base for a multi-select combo box column. Basically you should create a custom editor by inheriting the standard RadComboBoxEditor. You can find more information regarding this behavior in our online documentation. Please check also "GridView -> Custom Editors" example in our demo application.
Handle EditorRequired event to replace the default editor in RadGridView:
void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e) |
{ |
if (e.EditorType == typeof(RadComboBoxEditor)) |
{ |
e.EditorType = typeof(CustomComboBoxEditor); |
} |
} |
You can use a standard combobox column to host the editor:
GridViewLookUpColumn combo = new GridViewLookUpColumn("Items"); |
combo.DataType = typeof(string); |
this.radGridView1.Columns.Add(combo); |
Find the rest of the code in the attached C# file. I hope it helps. Should you have any questions, don't hesitate to ask.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I'm also trying to get a multi select combobox working inside a gridview column. I want the combobox's ItemsSource to be linked to an observable collection. I'm using WPF radcontrols version Q3 2011 and the sample code provided is deprecated.
What would be the right way to do this with a newer radcontrols API?
Thanks!
Please note that the current thread concerns the Windows Forms technology and suite rather than the WPF ones. I would kindly ask you to open a new thread in the appropriate forum section. This will allow those of our community who are interested in the same functionality for WPF to find the answer more easily. Thank you for your understanding.
All the best,Nikolay
the Telerik team
I need a combo box column which is capable of selecting multiple items from it. I refereed the KB article at this DEMO. which works fine for me. But i can not read values from it and can not set selected values in data binding.
Hope i am clear ...Please help.
Thanks.
Thank you for contacting Telerik support.
If I understand you correctly you are trying to combine the solution from this article with this one. In this case you can use the first example and bind the grid to a datasource like this:
public
Form1()
{
InitializeComponent();
DataTable t =
new
DataTable();
DataTable s =
new
DataTable();
s.Columns.Add(
"MutiSelect column"
,
typeof
(
int
[]));
s.Rows.Add(
new
int
[] { 9, 6, 10 });
s.Rows.Add(
new
int
[] { 5, 1, 3 });
s.Rows.Add(
new
int
[] { 8, 7 });
s.Rows.Add(
new
int
[] { 4, 2, 1 });
t.Columns.Add(
"ID"
,
typeof
(
int
));
t.Columns.Add(
"Name"
,
typeof
(
string
));
t.Rows.Add(1,
"one"
);
t.Rows.Add(2,
"two"
);
t.Rows.Add(3,
"three"
);
t.Rows.Add(4,
"four"
);
t.Rows.Add(5,
"five"
);
t.Rows.Add(6,
"six"
);
t.Rows.Add(7,
"seven"
);
t.Rows.Add(8,
"eight"
);
t.Rows.Add(9,
"nine"
);
t.Rows.Add(10,
"ten"
);
radGridView1.AutoGenerateColumns =
false
;
radGridView1.DataSource = s;
CustomColumn col =
new
CustomColumn(
"MutiSelect column"
);
col.DataSource = t;
col.DisplayMember =
"Name"
;
col.ValueMember =
"ID"
;
radGridView1.Columns.Add(col);
}
I hope this helps. Should you have any other questions do not hesitate to ask.
Dimitar
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 >>
Could you update multiselectcombobox to current version of telerik?
Some classes are obsolete for example RadListBoxItemCollection.
Thanks
Regards
Tom
Thank you for writing.
Please note that currently we support multi select drop down list out of the box. You can find detailed information about it here: CheckedDropDownList. The control can be used as editor in RadGridView as well: Use as RadGridView editor.
I hope this helps.
Regards,
Dimitar
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.
I have been waiting for this functionality but in example http://www.telerik.com/help/winforms/dropdown-and-listcontrol-checked-dropdownlist-how-to-use-as-radgridview-editor.html
I have problem with GridViewCheckedDropDownListEditor.
I have error:
"Error 10 The type or namespace name 'GridViewCheckedDropDownListEditor' could not be found (are you missing a using directive or an assembly reference?)"
Could you little help me?
Regards,
Tom
Thank you for writing.
It appears that there is a problem in our documentation page and the code is not listed there (we will fix this as soon as possible). Nevertheless the code for the editor should look like this:
public
class
GridViewCheckedDropDownListEditor : RadCheckedDropDownListElement
{
public
override
object
Value
{
get
{
return
this
.Text;
}
set
{
this
.Text = value +
""
;
}
}
}
Please let me know if there is something else I can help you with.
Dimitar
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.
i following the example, but what type can be the column of grid with this editor?
How can i store and retrieve then changes of this column?
Best Regards
Tasos
In the example, the column is added with this code:
this
.radGridView1.Columns.Add(
"CheckedDropDownListColumn"
);
This will add by default a GridViewTextBoxColumn.
I hope this helps.
Stefan
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.
This means that i must have a text field for this column?
if there are ids for each item in checkdropdown list what is the type for radgridview column?
Best Regards
That is correct. The example uses text field and its values are separated with ';'. Here is an example:
DataTable table =
new
DataTable();
table.Columns.Add(
"col1"
);
table.Columns.Add(
"col2"
);
table.Rows.Add(
"Model 1;Model 4;"
,
"value1"
);
table.Rows.Add(
"Model 3;Model 5;"
,
"value2"
);
radGridView1.DataSource = table;
Regards,
Stefan
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.
Can you give me an example please, how can i store integers but to show text (descriptions)?
Can i use a second table to store my selections which they be integers, but the column to show me the description if the selected IDs?
Best Regards
Thank you for writing back.
I have created a small sample where you can see how to convert the integer values to strings and vice versa. Please note that when you are not in edit mode the cell is always displaying text (you can display anything you want regardless of the value). This means that the value should be converted when the user begins or ends editing a particular cell. This is done by overriding the Value property of the editor - so when the editor is initialized the value is converted to string and when the user ends the edit, the value is converted back to integer.
I hope this will be useful.
Regards,
Dimitar
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.
Hello Jack I am new to Telerik.
my VS can't find RadComboxEditor, RadComboBoxItem and others.
Can you tell me where they are located?
I suppose that you are using the latest version of the Telerik UI for WinForms suite.
I would like to note that RadComboBox has been replaced by RadDropDownList. RadGridView now uses a RadDropDownListEditor: https://docs.telerik.com/devtools/winforms/controls/gridview/editors/default-editors
In case you want to allow multiple selection in the grid's editor, the following help article demonstrates how adopt RadCheckedDropDownList as an editor: https://docs.telerik.com/devtools/winforms/controls/dropdown-listcontrol-and-checkeddropdownlist/checkeddropdownlist/how-to/use-as-radgridview-editor
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.