I am trying to retrieve the data from a Property Grid and am at a loss on how to do it. I have found lots of articles on how to fill one; just not one on retrieving the data. I would like to put this data into a text format.
a little more information: this is an application that I am maintaining the Property grid is filled by a multitude of classes and methods that read and translate a binary file. It would take a substantial effort to modify the existing code to provide the information that I am looking for, including translating the file a second time. Considering that the data that I need is already in the property grid...
here is what I am doing to fill the grid:
protected virtual void OnSelectedTransactionChanged()
{
if (selectedTransaction != null)
{
journalPropertyGrid.SelectedObject = selectedTransaction.GetJournal();
I have added this code and it is not working my syntax is off:
PropertyGrid pg = new PropertyGrid();
PropertyDescriptor pd;
PropertyDescriptorCollection pdc;
StringBuilder str = new StringBuilder();
pdc = TypeDescriptor.GetPropertie(journalPropertyGrid.SelectedObject, true);
foreach (PropertyDescriptor pd in pdc)
{
str.AppendFormat("{0} =", pd.Name);
str.AppendFormat("{0}", (pd.GetValue(pg.SelectedObject)));
str.AppendFormat("\r\n");
}
string text = str.ToString();
txtJournal.Text = text;
I am using Visual Studio 2005, C#
Thank you in advance