C
Claude
Here's an homemade Attribut class :
public class Attribut
{
string m_sName;
object m_oValue;
public string Name { get { return m_sName;} }
public object Value { get { return m_oValue; } set { m_oValue = value; } }
public override string ToString()
{
if (m_oValue != null)
return m_oValue.ToString();
else
return "";
}
}
Here's a business object
public class MyObject
{
Attribut m_oAtt1;
Attribut m_oAtt2;
Attribut m_oAtt3;
public Attribut1 Att1 { get { return m_oAtt1;} set { m_oAtt1 = value; }}
...
}
Here's a collection of my business object
public MyObjectCollection : CollectionBase
{
....
}
I set the datasource of my DataGridView with my homemade collection.
Everything goes fine. The data is rendered correctly.
The problem happens when I try to modify, for example column 1 that
corresponds to Att1, an error occurs saying that the DataGridView can't
convert from System.String to MyAssembly.Attribut.
I know why it acts this way, but what I need to know is how can I bind the
sub-property Value of the more complex object Attribute in my class MyObject
in the DataGridView cell ? (So that the DataGridView can modify the Value of
the Attribute and not the Attribute object itself).
==> My english is a bit rusty, sorry.
Thanks,
Claude
public class Attribut
{
string m_sName;
object m_oValue;
public string Name { get { return m_sName;} }
public object Value { get { return m_oValue; } set { m_oValue = value; } }
public override string ToString()
{
if (m_oValue != null)
return m_oValue.ToString();
else
return "";
}
}
Here's a business object
public class MyObject
{
Attribut m_oAtt1;
Attribut m_oAtt2;
Attribut m_oAtt3;
public Attribut1 Att1 { get { return m_oAtt1;} set { m_oAtt1 = value; }}
...
}
Here's a collection of my business object
public MyObjectCollection : CollectionBase
{
....
}
I set the datasource of my DataGridView with my homemade collection.
Everything goes fine. The data is rendered correctly.
The problem happens when I try to modify, for example column 1 that
corresponds to Att1, an error occurs saying that the DataGridView can't
convert from System.String to MyAssembly.Attribut.
I know why it acts this way, but what I need to know is how can I bind the
sub-property Value of the more complex object Attribute in my class MyObject
in the DataGridView cell ? (So that the DataGridView can modify the Value of
the Attribute and not the Attribute object itself).
==> My english is a bit rusty, sorry.
Thanks,
Claude