Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / July 2007

Tip: Looking for answers? Try searching our database.

enable multi selection in dataGrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gidi - 20 Jul 2007 14:24 GMT
Hi,

I've a dataGrid which i overide the MouseUp event.
now, the user can select only one row, and  i want to give the user the
option to select few rows when he presses the CTRL+Mouse (like usually done),
and i can't find the way to do it.

my MouseUp function looks like this:

private void dataGrid1_MouseUp(object sender, Windows.Forms.MouseEventArgs e)
{

    System.Drawing.Point pt = new Point(e.X, e.Y);
    DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt);
    if(hti.Type == DataGrid.HitTestType.Cell)
    {
    dataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column);
    dataGrid1.Select(hti.Row);
    }
    m_row=dataGrid1.CurrentCell.RowNumber;
}

Thanks,
Gidi
Adrian Voicu - 20 Jul 2007 18:58 GMT
I don't think I understand what you are trying to achive with the code you
posted. To enable multi row selection in a datagridview, make sure the
MultiSelect property is set to true and the SelectionMode of the datagridview
is set to FullRowSelect. This way you can select single rows by clicking on
them once with the mouse, and multiple rows by holding down ctrl and clicking
on them with the mouse which is what I think you are after.

Adrian.
Signature

[Please mark my answer if it was helpful to you]

> Hi,
>
[quoted text clipped - 20 lines]
> Thanks,
> Gidi

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.