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

AllowMultiRowSelection

11 Answers 305 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ilya
Top achievements
Rank 1
Ilya asked on 19 Sep 2007, 11:32 AM
Hi,
How to make MultiRowSelection in WinForm GridView.

11 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 19 Sep 2007, 04:19 PM
Hi Ilya,

Multirow selection is only available in our latest release Q2 2007. To allow multiple row selection set the MultiSelect property to true and SelectionMode to GridViewSelectionMode.FullRowSelect.

this.radGridView1.MultiSelect = true;  
this.radGridView1.SelectionMode = GridViewSelectionMode.FullRowSelect; 

You can monitor when selected rows are changed by attaching to SelectionChanged event. All selected rows are available through SelectedRows collection.

this.radGridView1.SelectionChanged += new EventHandler(radGridView1_SelectionChanged);  
void radGridView1_SelectionChanged(object sender, EventArgs e)  
{  
    int i = 0;  
    foreach (GridViewRowInfo row in this.radGridView1.SelectedRows)  
         i += (int)row.Cells[0].Value;  

Hope this helps. Please contact us again, if we can be of any further assistance.

All the best,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Louis
Top achievements
Rank 1
answered on 15 Oct 2007, 06:42 PM
One question here regarding this event.
When i click in the grid but not on a row, this event is raised with SelectedRows.Count == 0, which is ok but the grid shows a selected row??
If i look in the CurrentRow, there is something? shouldn't the SelectedRows.count == 1 when the CurrentRow is set ?

I'm deleting rows when a user is pressing a button. First select the rows you want to delete and then delete them. but the problem is that CurrentRow and SelectedRows are different things. Why? both shows as selected in my grid.
0
Jack
Telerik team
answered on 16 Oct 2007, 03:45 PM
Hello Louis ,

CurrentRow is synchronized with the RadGridView currency manager and its Position property. Only one row in the RadGridView can be set as current. On the other hand, SelectedRows represents a collection of rows selected by the user using keyboard or the mouse. Maybe the issue is that the CurrentRow and the SelectedRows have the same visual representation in standard RadGridView themes. We will reconsider this for our next major release Q3.

You are correct - SelectedRows must be set when the CurrentRow is set by mouse click. We will correct this behavior in our next service pack. We have added 500 points to your account for the suggestion.

Thank you for writing, and please, don't hesitate to contact us if you have other questions.


Kind regards,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Benny
Top achievements
Rank 1
answered on 21 Apr 2010, 10:57 AM
What's the best way to avoid deselection of the selected rows when clicking an already selected row?
I'm developing a drag&drop application and the user needs to be able to drag multiple rows at once.

Scenario
1. User selects three rows
2. User clicks one of the selected rows to start dragging but the previous rows gets deselected and only one row is dragged.
0
Jack
Telerik team
answered on 21 Apr 2010, 02:33 PM
Hi Benny,

This could be achieved by replacing the default grid behavior. Please consider the sample code snippet below:

this.radGridView1.GridBehavior = new CustomGridBehavior();
public class CustomGridBehavior : BaseGridBehavior
{
    public override bool OnMouseDown(MouseEventArgs e)
    {
        GridCellElement cell = GridControl.ElementTree.GetElementAtPoint(e.Location) as GridCellElement;
        if (e.Button == MouseButtons.Left && cell != null && cell.RowInfo.IsSelected)
        {
            return true;
        }
        return base.OnMouseDown(e);
    }
}

I hope this helps.

Regards,
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.
0
Benny
Top achievements
Rank 1
answered on 07 May 2010, 12:55 PM
Hi Jack,

Your solution is blocking my drag and drop because I start the drag on the MouseDown-event in my main form.
If a row is (or multiple rows are) selected, my drag event isn't fired anymore because the event is interrupted in the CustomGridBehavior.

Therefore I needed to fire this event manually:
this.radGridView1.GridBehavior = new CustomGridBehavior(); 
public class CustomGridBehavior : BaseGridBehavior 
    public override bool OnMouseDown(MouseEventArgs e) 
    { 
        GridCellElement cell = GridControl.ElementTree.GetElementAtPoint(e.Location) as GridCellElement; 
        if (e.Button == MouseButtons.Left && cell != null && cell.RowInfo.IsSelected) 
        { 
            Grid.StartDrag( base.GridControl, e.Location ); // start dragging 
            return true
        } 
        return base.OnMouseDown(e); 
    } 
 

Just to let you know :o)
Thanks for the provided solution!
0
Jack
Telerik team
answered on 10 May 2010, 03:58 PM
Hello Benny,

I am glad to hear that you have found a solution for this issue and thank you for sharing it. If you have other questions, we will be glad to help further.

 

All the best,
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.
0
Dipak
Top achievements
Rank 1
answered on 01 Sep 2010, 06:49 PM
Hi

I have same issue when user select all the rows and right click to open context menu and looses selection.
I tried with CustomGridBehaviour but it is not opening Context Menu.
Could you please help me to resolve this issue?

Thanks
Dipak
0
Jack
Telerik team
answered on 03 Sep 2010, 12:30 PM
Hello Dipak,

I confirm that this issue appeared in old versions of RadGridView. However, it should have been addressed in our latest release - Q2 2010 SP1. Could you confirm that you are using the latest release? If yes, please open a new support ticket and send me your application and I will try to locate the issue.

I am looking forward to your reply.
 
Regards,
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
0
Dipak
Top achievements
Rank 1
answered on 03 Sep 2010, 05:23 PM
Hi Jack

I am using Q2 2010 Sp1 it persists in this version. I have also tried with interim build XXX.825 and experiencing same issue in that.

Thanks

Dipak
0
Jack
Telerik team
answered on 03 Sep 2010, 05:50 PM
Hi Dipak,

Please, send me your application. This will help us to locate and address the issue. Thank you in advance.

Greetings,
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
Ilya
Top achievements
Rank 1
Answers by
Jack
Telerik team
Louis
Top achievements
Rank 1
Benny
Top achievements
Rank 1
Dipak
Top achievements
Rank 1
Share this question
or