MappingName property
-
I am trying to map my ArrayList of type CRelation to data grid. CRelation class has two properties Child and Parent, both are of type CTable
public class CRelation { public CRelation() { // // TODO: Add constructor logic here // } private CTable m_oPrntTbl; public CTable Parent { set {m_oPrntTbl=value;} get{return m_oPrntTbl;} } private CTable m_oChldTbl; public CTable Child { set {m_oChldTbl=value;} get{return m_oChldTbl;} } } public class CTable { public CTable() { // // TODO: Add constructor logic here // } private string m_szName; public string Name { set{m_szName = value;} get{return m_szName;} } }
Now i want to map the grid column to Name property of the Child I am using following code to map the propertyDataGridTextBoxColumn dgcCol = new DataGridTextBoxColumn(); dgcCol.MappingName = "Child.Name";
Code above does not work. Am i doing something wrong here? Thanks -
I am trying to map my ArrayList of type CRelation to data grid. CRelation class has two properties Child and Parent, both are of type CTable
public class CRelation { public CRelation() { // // TODO: Add constructor logic here // } private CTable m_oPrntTbl; public CTable Parent { set {m_oPrntTbl=value;} get{return m_oPrntTbl;} } private CTable m_oChldTbl; public CTable Child { set {m_oChldTbl=value;} get{return m_oChldTbl;} } } public class CTable { public CTable() { // // TODO: Add constructor logic here // } private string m_szName; public string Name { set{m_szName = value;} get{return m_szName;} } }
Now i want to map the grid column to Name property of the Child I am using following code to map the propertyDataGridTextBoxColumn dgcCol = new DataGridTextBoxColumn(); dgcCol.MappingName = "Child.Name";
Code above does not work. Am i doing something wrong here? ThanksFirst of all, don't prefix your classes with "C". This is an obsolete naming convention in the .NET Framework and all other CLI implementations. It's important to remain consistent with the .NET Framework because it is a RAD environment (Rapid Application Development). Have any of the classes you've used in the .NET Framework Class Library started with "C" (sans classes like
CollectionBase
orControl
)? You won't find a single one. Read Naming Guidelines[^] for more information. Second, you really should read about theDataGridTableStyle.MappingName
property. See http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsDataGridTableStyleClassTopic.asp[^]. In it, it states that theDataGridTableStyle.MappingName
must be set to the class name that theArrayList
- or just a simple array - contains. YourDataGridColumnStyle
-derivatives then just contain the property name likeName
. The documentation above gives an example using a simple array, but anArrayList
works the same so long as you contain only one type (more than one type causes the first type to be used and any other types will not be bound). This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]