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

Multiple Cells Selection

3 Answers 107 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hendra
Top achievements
Rank 1
Hendra asked on 06 Jul 2009, 10:55 PM
I was searching through the samples, but I cannot find a sample code that will enable the user to perform multi cells selection. The user needs to be able to select multiple cell from the same row or other rows. Each selected cells will have different background and foreground color.

Thank you,
Hendra

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 07 Jul 2009, 12:36 PM
Hi Hendra,

Thank you for contacting us.

You should set RadGridView.MultiSelect property to true and RadGridView.SelectionMode to CellSelect. This will turn on the multiple cell selection mode. Please take a look at the Selection example in our Demo application. It demonstrates this behavior in detail.

You could use the Visual Style Builder to change cell appearance or you can use CellFormatting event. The IsSelected property indicates whether a cell is selected and the SelectedCells collection contains all selected cells.

If you have any other questions, don' t hesitate to ask.

Greetings,
Jack
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.
-1
Rami
Top achievements
Rank 1
answered on 27 Feb 2012, 10:43 AM
On GridView multi cell selection right click menu copy copies only one cell (the one that was right clicked) and that is different from Ctrl+C that copies multi cells. Why?
When copy single or multi cell , on GridView, (by Ctrl+C/Ctrl+V or by menu) and paste it, “CellValidating” event and “ValueChanging” is NOT triggered (for each cell). Why?

0
Jack
Telerik team
answered on 29 Feb 2012, 06:53 PM
Hello Rami,

Thank you for bringing our attention to this issue. I logged it in our issue tracking system and it will be addressed in our upcoming Service Pack in mid-March. I updated also your Telerik points.

You can work around the issue by replacing the default copy menu item with a custom one. Here is a sample:
void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
    foreach (RadMenuItemBase item in e.ContextMenu.Items)
    {
        if (item.Text == "Copy")
        {
            e.ContextMenu.Items.Remove(item);
            item.Dispose();
            break;
        }
    }
    RadMenuItem copyMenuItem = new RadMenuItem("Copy");
    copyMenuItem.Click += new EventHandler(copyMenuItem_Click);
    e.ContextMenu.Items.Insert(0, copyMenuItem);
}
 
void copyMenuItem_Click(object sender, EventArgs e)
{
    this.radGridView1.MasterTemplate.Copy();
}

Should you have further questions, do not hesitate to contact us.
 
Greetings,
Jack
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Hendra
Top achievements
Rank 1
Answers by
Jack
Telerik team
Rami
Top achievements
Rank 1
Share this question
or