473,471 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Question about the scroll arrows in DataGrid

hello
i have a DataGrid table and by the help of Adnan, here in the forum, i have the Mouse_up Event that by Clicking a row on the dataGrid it's selectes the whole ro
the problem is when i'm pressing the scroll arrows (to move the rows up\down\left\right) the whole stays selected except the cell which i pressed
how can i prevent that from hapenning

here with the Mouse_Up method

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

m_X=e.X
m_Y=e.Y
DataGrid myGrid = (DataGrid)sender
DataGrid.HitTestInfo myHitInfo = myGrid.HitTest(e.X, e.Y)
if (myHitInfo.Type == DataGrid.HitTestType.Cell || myHitInfo.Type == DataGrid.HitTestType.RowHeader

myGrid.Select(myHitInfo.Row)
myGrid.CurrentRowIndex = myHitInfo.Row
int someSampleID = Convert.ToInt32(myGrid[myHitInfo.Row,0])

thank you all
Gid

Nov 16 '05 #1
1 1877
Gidi,

The HitTest class doesn't seem to have information about scroll bars, so
I think you have to determine that yourself. Basically, what you want to do
is find out how wide the scroll bar is (or guess). Once you have that, in
the mouse up event, check to see if the number of visible rows is less than
the number of rows available. If this is the case, the scroll bar is being
shown, and you should not select the row if the x coordinate falls within
the boundary on the right side of the screen where the scrollbar would be.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Gidi" <sh*****@hotmail.com> wrote in message
news:B2**********************************@microsof t.com...
hello,
i have a DataGrid table and by the help of Adnan, here in the forum, i have the Mouse_up Event that by Clicking a row on the dataGrid it's selectes
the whole row the problem is when i'm pressing the scroll arrows (to move the rows up\down\left\right) the whole stays selected except the cell which i
pressed. how can i prevent that from hapenning?

here with the Mouse_Up method:

private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) {
m_X=e.X;
m_Y=e.Y;
DataGrid myGrid = (DataGrid)sender;
DataGrid.HitTestInfo myHitInfo = myGrid.HitTest(e.X, e.Y);
if (myHitInfo.Type == DataGrid.HitTestType.Cell || myHitInfo.Type == DataGrid.HitTestType.RowHeader ) {
myGrid.Select(myHitInfo.Row);
myGrid.CurrentRowIndex = myHitInfo.Row;
int someSampleID = Convert.ToInt32(myGrid[myHitInfo.Row,0]);
}
}

thank you all,
Gidi

Nov 16 '05 #2

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

Similar topics

3
by: Devonish | last post by:
I have a form designed as a Continuous form which displays one record per line. Taking account of the header and footer and the size of the screen, I can display 30 records at a time. I can see...
3
by: Devonish | last post by:
I have a form designed as a Continuous form which displays one record per line. Taking account of the header and footer and the size of the screen, I can display 30 records at a time. I can see...
1
by: Gidi | last post by:
Hi, I have DataGrid and i want to use the arrows to navigate up and down between the lines. i also want that each row i'm in, will be marked (as in DataGrid.Select(row_number)). When my form is...
2
by: Peter Proost | last post by:
Hi I've got a question about the visual studio 2005 SP1 IDE. The events combo (the combo in the code editor where you select the event you want to handle) is realy slow when I scroll it. It opens...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.