Avatar of ukerandi
ukerandi
Flag for United Kingdom of Great Britain and Northern Ireland asked on

C# - Winform

Hi See below my code
  private void dataGridViewFranceCube_CellContentClick(object sender, DataGridViewCellEventArgs e)
            {
                DataGridViewRow rowNumber = dataGridViewFranceCube.SelectedRows[0];
                txtitem.Text = rowNumber.Cells[0].Value.ToString();
                txtProductDescription.Text = rowNumber.Cells[2].Value.ToString();
            }

Open in new window


Sometime this is not working, any idea where im doing mistake, What i need is ,when user click i need to get row data for example
if user click on row 2 i need column1 and column 2 data.
C#.NET Programming

Avatar of undefined
Last Comment
Franck Gaspoz

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Naitik Gamit

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ukerandi

ASKER
private void dataGridViewFranceCube_CellClick(object sender,  DataGridViewCellEventArgs e)
            {
                MessageBox.Show("Test");

           

                DataGridViewImageCell cell = (DataGridViewImageCell)
                    dataGridViewFranceCube.Rows[e.RowIndex].Cells[e.ColumnIndex];

               

             
            }


and also i have add following code to Designer.cs also but still not working

   this.dataGridViewFranceCube_CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewFranceCube_CellClick);
Franck Gaspoz

Hi,
do you have any exception thrown ? if yes can you show it ?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy