Hi All,

I Got a issue when i restore the tag property value in datagrid. In my form having two text box and a button called add. i can able to add text box value into datagrid using bindsource class. PFB

EmpList se= new EmpList(textBox1.Text, textBox2.Text);
bindingSource1.Add(new EmpDetail(se.one, se.Two));
this.dataGridView1.Tag = selectedEmp;
dataGridView1.DataSource = bindingSource1;

Assume my grid having two rows and cols with some values. My problem is i cant restote the first row value by using Tag property when clicking ceelcontent click event. Always i am getting the (selectedEmp)values which has added recently. PFB

selectedEmp = (EmpList)dataGridView1.SelectedCells[0].DataGridView.Tag;

i need to get the exact row value(What i select on cell content row) using tag property and store them wrt textboxes.
Please tell me what i am doing wrong. TIA.

In the first snippet it seems like you are setting the .Tag member of the entire datagrid, not the individual cells/rows.

In the second snippet you are accessing the first index of the selected cells, then trying to get the tag member out of it's parent gridview.

I would try providing a meaningful tag to either the row or the cells as you add them, rather than using a tag member of the entire gridview.

thanks skatamatic. I resolved this issue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.