Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to add datagridview row contents in propertygrid control on cellcontentclick event of datagridview? Please help
Posted
Updated 28-Aug-11 19:06pm
v2

1 solution

i think to add a property to you property grid you need to add by using
PropertyGrid.selectedobject= {object} .

so create your needed class object into your main class

class main
{
....
....
....

class myobj
{
//take you needed arguments into strings depending on the number of columns

string one, two ;//three ...four...... as you need

// constructor, here you will take argument from your datagridviewRow
public myobj(dataGridViewRow R)
{
one = R.cells[0].value.tostring();
two = R.cells[1].valuse.tostring();
}

// now here's the properties that will be shown into the propertygrid

public string property1
{
get { return one ;}
}
public string property2
{
get { return two ;}
}
}//your class obj is finished

//now on the event cellenter (better than cellcontent click) (same code)

private void dataGridView1_CellEnter(object sender,DataGridViewCellEventArgs e)
{

myobj obj = new myobj(dataGridView1.Rows[e.RowIndex]);
propertyGrid1.SelectedObject = obj;//automatically the contents of . // row will be shown
}

........
........
.......


}
 
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