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

Cell selection and horizontal scrolling

3 Answers 178 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Metrik
Top achievements
Rank 1
Metrik asked on 09 Mar 2012, 06:16 PM
Hi,

I have a RadGridView in my WPF v2011.3.116.40 application. This RadGridView has 6 columns.

Let's say that the last column extends beyond the RadGridView and I have not selected any cell in this RadGridView, so only part of those cells are visible.
When I click on a cell of this column, my horizontal scrollbar is moved so as to show the entire contents of the cell.

I would like to override this behaviour so that selecting a cell does not shift my horizontal scrollbar, except if the keyboard navigation keys are used to select a cell that is not visible at all.
I have not found a property of RadGridView that would implement this.

I hope my question is clear.

Thanks.

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 14 Mar 2012, 12:58 PM
Hello Nichola,

Unfortunately, by default the GridView does not offer such functionality. You can use the SelectedCellChanging/Changed events to set the ScrollViewer's offset to implement the scenario. 

Please look into the attached project and see if this approach will work in your case. If you need any further assistance, please don't hesitate to ask! 

Regards,
Nik
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Metrik
Top achievements
Rank 1
answered on 14 Mar 2012, 03:52 PM
Hi Nik,

Thank you for your reply. From what I understand, your demo stores the horizontal scrollbar's value on the Changing event, then reapplies it on the Changed event. This sounds like the right approach, if flickering can be avoided.

However, what I see when I run the demo is that the horizontal scrollbar still has an offset. Here is how to try it:
- Run the GridViewCellSelectionExample
- Click on Row 1, Cell 10 (first row, 10th cell)
- The horizontal scrollbar is shifted so that "Items0" can be displayed entirely. Wouldn't we expect the scrollbar to keep the horizontal scroll offset value of 0 that it had when the application was started?

Regards
0
Nick
Telerik team
answered on 20 Mar 2012, 09:07 AM
Hi Nichola,

Yes you are right, it seems that there is a flaw in the example I sent. Unfortunately, since the default behavior of the GridView is not what you are looking for, the only workaround that we were able to find was to set the SelectionUnit to cell. Could you try it and see if it works for you? 

Hope this helps! 

Kind regards,
Nik
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Metrik
Top achievements
Rank 1
Answers by
Nick
Telerik team
Metrik
Top achievements
Rank 1
Share this question
or