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

Default value for GridViewComboBoxColumn

5 Answers 412 Views
GridView
This is a migrated thread and some comments may be shown as answers.
gmendez
Top achievements
Rank 1
gmendez asked on 14 Jul 2009, 07:47 PM
Hello,

I have two questions. I've created an unbound combo box column like this:

            const string aceptar = "Aceptar";
            GridViewComboBoxColumn aceptarColumn = new GridViewComboBoxColumn(aceptar, aceptar);
            aceptarColumn.HeaderText = aceptar;
            aceptarColumn.Width = 120;            
            aceptarColumn.DataType = typeof(String);
            aceptarColumn.DataSource = new String[] { "Sí", "No", "No lo sé" };
            gridViewPedidos.Columns.Add(aceptarColumn);

1) How can I set the default value to "No lo sé" (the 3rd element?) By defoult the combos are empty.

2) Is it possible to achieve this at design time? I mean, without having to write none of the above lines of code?

Best regards,

Gonzalo

5 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 16 Jul 2009, 04:42 PM
Hi Gonzalo,

Adding new columns is possible at design-time via the Property Builder dialog. You can access the dialog through the smart tag of RadGridView.

Unbound columns however cannot have a default value. You can nevertheless loop through all your rows, and set the value of the combo box cells to whatever you need. You can do this right after you add your GirdViewComboBoxColumn.

Write back if you need further assistance.

Sincerely yours,
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.
0
gmendez
Top achievements
Rank 1
answered on 16 Jul 2009, 06:45 PM
Hi Victor,

"Adding new columns is possible at design-time via the Property Builder dialog. You can access the dialog through the smart tag of RadGridView."

Yes, I know that. What I was relly trying to ask was if it's possible to add a combo box column and set it's items at design time. Currently I'm doing this:  
 
              aceptarColumn.DataSource = new String[] { "Sí", "No", "No lo sé" };

But as with the standard winforms combo box one can set the items at design time I was wondering if it's possible to do so when working with GridViewComboBoxColumn objects.


"Unbound columns however cannot have a default value. You can nevertheless loop through all your rows, and set the value of the combo box cells to whatever you need. You can do this right after you add your GirdViewComboBoxColumn."

Ok, I used a for statement for this, iterating the through the rows. But, may be using an event to set the desired value would be more elegant. Would you have any suggestion for this?

Thanks again.

Best regards,

Gonzalo
0
Accepted
Victor
Telerik team
answered on 17 Jul 2009, 11:06 AM
Hello Gonzalo,

Thank you for the questions.

I am afraid that explicitly setting the items of GridViewComboBox column at design-time is not yet possible. You can only set the column's DataSource. This is an interesting request and since the standard DataGridView supports such behavior, we will consider implementing it.

We do not provide an event for setting initial values to unbound column cells. This is also worth consideration and we will look into it.
 

Regards,
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.
0
govind
Top achievements
Rank 1
answered on 06 Sep 2012, 11:41 AM
Hi All,
Did you find any solution to this problem. I am facing the same problem.

Please update me ASAP.


Thanks
Govind.
0
Nikolay
Telerik team
answered on 10 Sep 2012, 07:42 AM
Hi Govind,

You can find the answer to your question in the support ticket that you have opened.

Kind regards,
Nikolay
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
gmendez
Top achievements
Rank 1
Answers by
Victor
Telerik team
gmendez
Top achievements
Rank 1
govind
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or