I am currently working on a bookmark manager application (Windows Forms), with advanced search capabilities.
I have created a Links class, and every time a user enters a URL, I’ll create a Link object and store the details there. It currently has the properties Name, URL and Tags, where Tags is a list.
At runtime when I set the DataSource property of a gridview to the List<Links> objects, the Name and the URL show up but the tags do not.
How do I go about displaying the list of tags inside the List<Links> object in the gridview?
EDIT: Just had an idea. What if I write a function to convert the List<Links> into a DataTable, and then set the DataSource property of the DataGrid to the DataTable?
The problem with this is that everytime a change is made to the List<Links> I will have to generate the DataTable again, which does not seem ideal from a performance point of view.
EDIT 2: I wish to display each item in the list as a DataGridViewTextBox column.
Thanks,
Abijeet.
Maybe this is what you want… an object that appears to have more properties that it actually has.
The
DataGridViewcontroll supports theComponentModelnamespace so that you can create classes that appear to have properties that don’t exist. It is the same mechanism thePropertyGriduses.Sample code
This sample is a fully working windows forms class, with a form containing a
DataGridView. I add some objects to is, using a list that is then set to theDataSourceproperty.The objects inside that list, have no properties at all… but they use component model to describe ‘virtual’ properties to the
DataGridView.