문제

I Have a WPF window that have a RadGridView and a Button, My requirement is, when you click on the button and select a row in the grid, it should work similar to pressing on the shift key and clicking on a gridview row. (To select multiple rows).

So, i need to press the shift key programatically in button click event.

Can this be done?

Appreciate if anyone can provide a solution

도움이 되었습니까?

해결책

Do not fire a KeyPress event manually. Rather, on this page, Telerik indicates that to allow multiple selection, you must set the SelectionMode to Extended:

this.radGridView.SelectionMode = System.Windows.Controls.SelectionMode.Extended;

So, put this in your button click (I guess you'll want it to toggle between Extended and Single. Multiple's behaviour is awkward, but that's just me) and you're good to go.

Edit:

The toggle button will have something like this in its click event handler:

private void toggleButton1_Click(object sender, RoutedEventArgs e)
{
    this.radGridView.SelectionMode = toggleButton1.IsChecked ? SelectionMode.Extended : SelectionMode.Single;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top