Binary Data in Data Grid :: C#
-
Hello. Given an array of binary data stored in an ArrayList container, do you associate the container as a datasource in a Data Grid control? private ArrayList xList = new ArrayList(); // Arbitrarily add 64 integers into container for (int i = 0; i < 64; ++i) this.xList.Add(i); // Assuming Data Grid was created via wizard thisTheDataGrid.DataSource = this.xList; thisTheDataGrid.Refresh(); The example above compiles okay. However, nothing shows up in the data grid. All you would see is 64 empty rows and no columns. Do you need to set a specific property to show arbitrary data in the grid? Thanks, Kuphryn
-
Hello. Given an array of binary data stored in an ArrayList container, do you associate the container as a datasource in a Data Grid control? private ArrayList xList = new ArrayList(); // Arbitrarily add 64 integers into container for (int i = 0; i < 64; ++i) this.xList.Add(i); // Assuming Data Grid was created via wizard thisTheDataGrid.DataSource = this.xList; thisTheDataGrid.Refresh(); The example above compiles okay. However, nothing shows up in the data grid. All you would see is 64 empty rows and no columns. Do you need to set a specific property to show arbitrary data in the grid? Thanks, Kuphryn
You can use any
IList
orIListSource
implementation (ArrayList
implementsIList
). If you have anyDataGridTableStyle
s configured in theDataGrid.TableStyles
property, you must set theDataGridTableStyle.MappingName
to the type, i.e. "ArrayList", so that it is mapped correctly.Microsoft MVP, Visual C# My Articles
-
You can use any
IList
orIListSource
implementation (ArrayList
implementsIList
). If you have anyDataGridTableStyle
s configured in theDataGrid.TableStyles
property, you must set theDataGridTableStyle.MappingName
to the type, i.e. "ArrayList", so that it is mapped correctly.Microsoft MVP, Visual C# My Articles
-
Okay. Thanks. I tried inserting "ArrayList" as the mapping name for the tablestyle. That did not make a difference. The problem is still that nothing shows up in the Data Grid. In fact, there are no grid line. All I see are row borders. Kuphryn
If you are using table styles and they don't apply to the current data binding, that what you should expect to see. Instead of an
ArrayList
, use anint[]
array and use "int[]" as theDataGridTableStyle.MappingName
. See the documentation forDataGridTableStyle.MappingName
in the .NET Framework SDK for more information. Are you even using table styles? If so, maybe try not adding them and you should see something. Again, a data source can be anything that implementsIList
orIListSource
. Some controls'DataSource
properties will even exceptIEnumerable
implementations as a last resort.Microsoft MVP, Visual C# My Articles