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

RadComboBoxElement inside GridCellElement

5 Answers 273 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 14 Apr 2009, 11:33 PM
Hello -

I am nesting a RadComboBoxElement under a GridCellElement (in my actual code, I'm nesting a larger element tree of which one of the elements happens to be a combo box, which is why I cannot use a GridViewComboBoxColumn).  I've almost achieved the desired behavior.  Here are the three remaining issues:

1)  Why doesn't clicking on the combo box's arrow button cause the dropdown to open up?  Is the grid somehow intercepting this event?
3)  When the Tab key is pressed, the current grid cell gets updated, but the keyboard focus is not moved from one combo box to the next.  Can you tell me how to make tab work properly?
2)  Why doesn't clicking into the combo box's RadTextBoxElement cause the current grid row to be adjusted (note that clicking on the arrow button does adjust the current grid row)?  I believe the answer may be that the textbox is intercepting the mouse click even though I set RadComboBoxElement.NotifyParentOnMouseInput to true.  What is the suggested workaround?

Here is some simple code that reproduces the problem:

        void grid_CellFormatting(object sender, CellFormattingEventArgs e) 
        { 
            if (e.CellElement.Children.Count == 0) 
            { 
                var element = new RadComboBoxElement(); 
                element.NotifyParentOnMouseInput = true
                element.DataSource = new List<string>() { "First""Second""Third" }; 
                e.CellElement.Children.Add(element); 
            } 
        } 
 
        void Form1_Load(object sender, EventArgs e) 
        { 
            var grid = new RadGridView(); 
            Controls.Add(grid); 
            grid.BeginInit(); 
            grid.EndInit(); 
            grid.CellFormatting += new CellFormattingEventHandler(grid_CellFormatting); 
            grid.MasterGridViewTemplate.AutoGenerateColumns = false
            grid.Columns.Add(new GridViewDataColumn() { HeaderText = "Header" }); 
            grid.DataSource = new List<int> { 1, 2, 3 }; 
        } 

Thanks,
- Mike


5 Answers, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 17 Apr 2009, 03:24 PM
Hi Michael,

In this case you should the corresponding grid column to ReadOnly to prevent grid from handling the mouse events when it tries to open cell editor. By default RadGridView processes mouse events focuses the cell that contains the ComboBox, which closes the dropdown of the combo immediately after it has been displayed. (Drop will be displayed though if you use keyboard (F4)) We have prepared you a sample.

Regarding the implementation of adding any elements in grid cells, the best approach would be as I demonstrated in the following thread:
http://www.telerik.com/community/forums/winforms/general-discussions/windows-control-size-limit.aspx
(grid and repeater sample) with creating custom grid cell.

You you wish the column to be editable, you can consider implementing custom grid editor which will appear in the cell only when it gets in edit mode. We have a sample for you regarding the approach as well.

I am afraid I do not quite well understand your third question. If you can elaborate a bit more on what you wish to achieve I will be happy to assist you.

All the best,
Mike
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
Michael
Top achievements
Rank 2
answered on 21 Apr 2009, 11:14 PM
Mike -

Thanks for the response.  My first question is now solved.  You attached two zip files to your previous response.  The first zip file, entitled "radgridviewcomboelement.zip" demonstrates both questions 2 and 3 below.  Here are the repro steps:

2)  Start the app.  Click on the *text* of the Value cell in the row with ID 2.  Note that the first row of the grid remains selected.  In contrast, click in the Name cell of the row with ID 3.  Note that the row is now selected.  Also, click on any combo box button.  Note that the corresponding row is now selected.  However, when clicking in the text of the combo box, the current row is not updated.
3)  Start the app.  Click on the *text* of the Value cell in the row with ID 2.  The text of the cell should now be selected.  Press the TAB key several times.  Notice that the grid is tabbing through various cells, but the combo box text remains selected.  Keyboard focus is not being moved between cells by the TAB key.

Thanks,
- Mike
0
Accepted
Mike
Telerik team
answered on 22 Apr 2009, 04:46 PM
Hi Mike,

Thank you prompt directions.
I have changed the code of the sample you referred and now, I think, problems 2 and 3 are solved. As an extra, I have also managed to focus the combo if you you click anywhere in the corresponding grid cell.

The changes are related to the code of the custom grid cell and I left some comments for your convenience. Let me know you need further assistance with this.

Kind regards,
Mike
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
Andrew Shyliuk
Top achievements
Rank 1
answered on 12 Mar 2010, 04:33 PM
Have you seen this samples?!?!?!
Please, add to grid 30 rows, increase the width of columns and get beautiful result (on the screenshot).
0
Jack
Telerik team
answered on 16 Mar 2010, 03:43 PM
Hello Andrew Shyliuk,

Yes, we know about this limitation. The scrollbars used in RadGridView are elements not controls, so they can't clip windows controls such as the textbox used in this example. A better option will be to use custom editors. A sample demonstrating this approach is available in our demo application. Find more details in our online help. I hope this helps.

 

Best wishes,
Jack
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Michael
Top achievements
Rank 2
Answers by
Mike
Telerik team
Michael
Top achievements
Rank 2
Andrew Shyliuk
Top achievements
Rank 1
Jack
Telerik team
Share this question
or