Display List<int> inside DataGridView

G

g18c

Hi, i have bound my list of objects to a data grid view (i have
actually used BindingList) and can add, edit objects ok. Sample object
is given below:

class MyObject
{
string m_Name;
public string Name
{
get { return m_Name; }
set { m_Name = value; }
}

List<int> m_List = new List<int>();
public List<int> MyList
{
get { return m_List; }
set { m_List = value; }
}
}

I can display and edit the name field ok. However, as you can see my
object also contains a List<int> but i am not given the option to
display this in the properties when i goto add a new column. How could
i go about displaying a list of ints (ideally i would like a custom
display, where i can list the ints, one to five in this example, in a
text box seperated by commas ie "1, 2, 3, 4").

Do i need to add the column manually, hook into the format event or
define my own cell types?

Thanks in advance,

Chris
 
G

g18c

One thing i forgot to ask is, is it ok to have to interfaces to my
object, one property which is a List<int> (already in my object above),
and to add an additional property one which is a string (called
MyStringList for example). The string property would accept the comma
list e.g. "1, 2, 3, 4" which i would parse and set the internal m_List
variable?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top