Find the row index on mouse click in datagridview it shows the error?

Posted by Sudheep.grandhe under C# on 11/8/2011 | Points: 10 | Views : 2074 | Status : [Member] | Replies : 3
Hi,

i am currently developing windows applications.i want to find the row index on mouse click in datagridview.please do the needful.

it's shows the following errors.
Error1The name '_theight' does not exist in the current context
Error 2The name '_location' does not exist in the current context
Error 3The name 'header' does not exist in the current context
Error 4The name 'int_theight' does not exist in the current context

private void GridView1_MouseClick(object sender, MouseEventArgs e)
{
int_theight = 0;
string location = "";
if (e.Y >= _theight && e.Y <= _theight + GridView1.ColumnHeadersHeight)
_location = header;
else
{
_location = "";
_theight = _theight + GridView1.ColumnHeadersHeight;
foreach (DataGridViewRow item in GridView1.Rows)
{
if (e.Y >= _theight && e.Y <= _theight + item.Height)
{
_location = "row index:" + item.Index;
break;
}
else
_theight = _theight + item.Height;
}
if (_location == "")
_location = "outside";
}
MessageBox.Show("_location");


}
}

Best,
Sudheep.



Responses

Posted by: Blessyjees on: 11/8/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Please tell the purpose this code/event. I am not fully clear your code.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 11/8/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Find the row index on mouse click in datagridview

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 11/8/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

I want to show the no's under the grid view like 1 2

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response