Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get the selected column number or column header in datagridview, when doubleclick is made?
and i want to place date time picker in that column.
the code which I have used is this one:
void DataGridView1DoubleClick(object sender, EventArgs e)
{
MouseEventArgs args = (MouseEventArgs)e;
Point p = dataGridView1.PointToClient(new Point(args.X,args.Y));
DataGridView.HitTestInfo info = dataGridView1.HitTest(p.X, p.Y);
int Row = info.RowIndex;
int Col=info.ColumnIndex;
 
if(dataGridView1.Columns[info.ColumnIndex].Name == "Employee name")
     {

textBox1.Text="hello";            	textBox1.SetBounds(args.X,args.Y,dataGridView1.CurrentCell.Size.Width,dataGridView1.CurrentCell.Size.Height);
            	textBox1.Show();
            }
}

but the row index and column index is returned as -1
I have used checkbox column at column[0] is this because of that??
thanks in advance
Posted
Updated 30-Mar-11 1:05am
v3

1 solution

this is the solution i found which gives me the column value selected.but now my question is how to place text box inside that cell..

int Col=dataGridView1.CurrentCellAddress.X;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900