Click here to Skip to main content
15,904,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know that there is no datagridview.performclick event.
But I have a cell that is (0) and column (0)and need to
scan a barcode in a textbox and have that column programatically clicked.
I have searched the web and MS forums but can't find any working answers.
Is it possible at all to call a perform click on a specific cell or column in a datagridview? This is for vb net. Of Course an answer in C# would help too.
Updated 8-Nov-10 1:33am

1 solution

You can do it easily with a bit of javascripting.

Make 3 hidden fields:
<input runat=server type=hidden id=inhAction />
<input runat=server type=hidden id=inhRow />
<input runat=server type=hidden id=inhColumn />

and a javascript function:
function cellClicked(row, column){
myForm.inhAction.value = "CELLCLICKED";
myForm.inhRow.value = row;
myForm.inhColumn.value = column;

and in the gridview's RowDataBound event setup the javascript call for every
myCellRow, myCellColumn);

When you click a cell, you will get a postback. You can tell taht the
postback is caused by a cell click by looking in the inhAction and you can
get the row and the column numbers from the inhRow and inhColumn.

Please vote and Accept Answer if it Helped.
Share this answer
mindserve 8-Nov-10 7:32am    
Is there a way to do this in vb net without javascript?

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