473,602 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ 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\ri ght) 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_Mouse Up(object sender, System.Windows. Forms.MouseEven tArgs e

m_X=e.X
m_Y=e.Y
DataGrid myGrid = (DataGrid)sende r
DataGrid.HitTes tInfo myHitInfo = myGrid.HitTest( e.X, e.Y)
if (myHitInfo.Type == DataGrid.HitTes tType.Cell || myHitInfo.Type == DataGrid.HitTes tType.RowHeader

myGrid.Select(m yHitInfo.Row)
myGrid.CurrentR owIndex = myHitInfo.Row
int someSampleID = Convert.ToInt32 (myGrid[myHitInfo.Row,0])

thank you all
Gid

Nov 16 '05 #1
1 1885
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.co m

"Gidi" <sh*****@hotmai l.com> wrote in message
news:B2******** *************** ***********@mic rosoft.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\ri ght) 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_Mouse Up(object sender, System.Windows. Forms.MouseEven tArgs e) {
m_X=e.X;
m_Y=e.Y;
DataGrid myGrid = (DataGrid)sende r;
DataGrid.HitTes tInfo myHitInfo = myGrid.HitTest( e.X, e.Y);
if (myHitInfo.Type == DataGrid.HitTes tType.Cell || myHitInfo.Type == DataGrid.HitTes tType.RowHeader ) {
myGrid.Select(m yHitInfo.Row);
myGrid.CurrentR owIndex = 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
3981
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 other records by scrolling up or down with either the scroll bar on the right of the screen, or the up and down arrows which are above and below this scroll bar; or I can use the scroll wheel
3
431
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 other records by scrolling up or down with either the scroll bar on the right of the screen, or the up and down arrows which are above and below this scroll bar; or I can use the scroll wheel
1
1681
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 loaded, my focus is on a textbox i have, and what i want to do is that if i press the arrows keys the focus will be on the dataGrid (on the next row) and while i'll navigate with arrows, the row i will be in will be totaly marked. how can i do...
2
1271
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 fast , but if I for example scroll the scrollwheel on my mouse 3 times there's a delay of a 1 second per scroll, it's the same when using the scrollbar arrows. Has anyone experienced the same thing or does anyone now what the problem could be....
0
7993
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8268
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6730
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2418
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 we have to send another system
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.