Click here to Skip to main content
15,886,678 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here is what I did wrong I started a new C# project and created a form
then I opened a VB.Net project and copied a DataGridView (DGV) that was on a
form and pasted it into my C# form.
Populated the DGV from the SQLite DB great it worked.
Proceeded to write code to capture the values in the DGV cells.
After more hours I care to admit to NOTHING was working.
Looking in the VS 2019 ToolBox I noticed two DGV one under All Windows Forms
and one under Data.
For anyone reading this POST I am guessing that you need to use the DGV
under All Windows Forms for VB.Net and for C# you need the DGV under Data.

So I am really asking is my guess CORRECT ?
How in the name of St. Novice do you know to use the one under Data?

What I have tried:

This is just the code I used to capture the values in the DGV by click on the cell. It is here because I am proud of it and it nice to contribute St.Novice
private void dgvPerson_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
    int ID = 0;// Declare this top level
    ID = Convert.ToInt32(dgvPerson.Rows[e.RowIndex].Cells[0].Value.ToString());
    tbID.Text = ID.ToString();
    tbFName.Text = dgvPerson.Rows[e.RowIndex].Cells[1].Value.ToString();
    tbLName.Text = dgvPerson.Rows[e.RowIndex].Cells[2].Value.ToString();
}
Posted
Updated 24-Jan-23 5:41am

Quote:
For anyone reading this POST I am guessing that you need to use the DGV
under All Windows Forms for VB.Net and for C# you need the DGV under Data.

No, you are wrong. The various tabs in the toolbox are merely for organizing controls into categories, and, in the case of "All Windows Forms", all of the controls can be found in one place. There is no difference at all between the "All Windows Forms" controls and the ones under the individual tabs, like Data. They are the exact same controls.

Even between VB.NET and C#, they are the exact same controls.
 
Share this answer
 
v2
Comments
BillWoodruff 23-Jan-23 21:10pm    
+5
OK Dave Kreskowiak I then believe the reason is because I copied and pasted from
a VB.Net application? I did test by using the DGV under All Windows Forms.
in the C# application. And it would not read the click event
Thanks for the Insight and Reply
YES both controls are the same ID from MS only difference is one is
BLUE and the other is BLACK
Either way it is fixed move on with learning C#
 
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