By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,089 Members | 1,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,089 IT Pros & Developers. It's quick & easy.

Question about the scroll arrows in DataGrid

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.