473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

enable multi selection in dataGrid

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
Jul 20 '07 #1
1 3717

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.
--
[Please mark my answer if it was helpful to you]


"Gidi" wrote:
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
Jul 20 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Susan Bricker | last post by:
Hi. I have two questions ... (1) I want to use a Listbox to enable the user to select 1 or many items from the list. However, I'm having trouble figuring out how to find out t which items have...
4
by: Ubi | last post by:
hello, i'm using a dataview to filter my table. how can i get a index (for the original table) of the selected rows (there can be more than 1). please help
0
by: Pete Davis | last post by:
Sorry to have to post this here, but none of the accessibility newsgroups seem to be active. I've got a custom control that I'm adding accessibility support to. The control is a grid control and...
6
by: Alpha | last post by:
I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on...
2
by: Alpha | last post by:
How I can disable multi-selection on a datagrid? User now can select multi-rows on the grid by holding down control key. I don't see such property for the grid as for the list control. Is there...
1
by: thegame | last post by:
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls Hello, I have an interesting dilemma. I have an ASPX page with two user controls (two ASCXs). ...
3
by: mark | last post by:
I have a numerical array which is displayed in a datagrid by way of a datatable and a dataview. I want my user to be able to select a sub-block of the grid's cells for subsequent...
1
by: mark | last post by:
I fear my initial post was misleading. I have a Windows application. I have a numerical array which is displayed in a datagrid by way of a datatable and a dataview. I want my user to be...
11
by: woodey2002 | last post by:
This problem is driving me crazy. Hello there, i am trying to create a search form for records in my access database. The search form will contain text boxes and a multi select list box. The user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.