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

GridViewComboBoxColumn in hierarchic GridView

5 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 1
Bruno asked on 08 Mar 2011, 10:02 AM

Hello,

I am new at using Telerik products.

I am using a GridView with Hierarchic levels.
I am trying to add a combo box in it, so I created a GridViewComboBoxColumn object , and added it to the GridView like this :

myGridView.MasterGridViewTemplate.Columns.Add(myComboBoxColumn);  and it works.

But now, I want to add the combo to the hierachical second level on the GridView, something like that :

myGridView.MasterGridViewTemplate.ChildGridViewTemplates.Insert(4,myComboBoxColumn);

but I get an error message telling that a GridViewComboBoxColumn object is not assignable to a GridViewTemplate.

So please can you tell me how I could add the GridViewComboBoxColumn to the GridView at this level ?

Thank you.

5 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 08 Mar 2011, 11:34 AM
Hello Bruno,

You can add any column to the GridViewTemplates collection like so:
var comboBoxColumn = new GridViewComboBoxColumn();
radGridView1.Templates[0].Columns.Add(comboBoxColumn);

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Bruno
Top achievements
Rank 1
answered on 08 Mar 2011, 12:24 PM

Thank you for your answer.

Now I can add the field to the grid, but when added, it doesn't react like a combo box, but just like an empty text box (???)
When I tried to add it to the higher level of the GridView (just for a test), it worked perfectly like a combo box.

Here is the code I use for adding the combo to the templates level of the GridView :

 

 

 

 

var myCombo= new GridViewAdvComboBoxColumn
            {
                FieldName = "MyValues",
                HeaderText = "Valeurs",
                MinWidth = 150,
                MaxWidth = 150,
                UniqueName = "MyValues",
                Width = 150,
                DataSource = SessionTabParent.AssociatedSession.InvoicingController.GetDataById(myId),
                DisplayMember = "myLabel",
                ValueMember = "myLabel"
            };
  
           myGridView.MasterGridViewTemplate.ChildGridViewTemplates[0].Columns.Add(myCombo);

0
Bruno
Top achievements
Rank 1
answered on 08 Mar 2011, 02:47 PM

Sorry, it seems that my GridView was in read-only mode, and that's why the Combo appeared like an empty textbox.
Now it works, but the dropdown part is not visible until I click on the combo field.

Is there a way to make it graphically obvious that it is a combo box, even when no clicking at it ?
0
Emanuel Varga
Top achievements
Rank 1
answered on 08 Mar 2011, 03:18 PM
Hello again,

No, sorry, this is the default behavior for a combo box in the grid.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Alexander
Telerik team
answered on 10 Mar 2011, 04:27 PM
Hello Bruno,

Thank you for your question.

As Emanuel said, the default behavior of GridViewComboBoxColumn is to show the DropDownList editor only in edit mode. You can create a Custom Cell to customize the cell elements and appearance according to your requirements.

I hope it helps.

Best wishes,
Alexander
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Bruno
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Bruno
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or