Binary Data in Data Grid :: C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 containe

for (int i = 0; i < 64; ++i
this.xList.Add(i)

// Assuming Data Grid was created via wizar
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
 
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

The DataGrid needs a publicly accessible property so that it knows what to
pull for its columns. Try this:

private void Form1_Load(object sender, System.EventArgs e)
{
ArrayList xList = new ArrayList();

// Arbitrarily add 64 integers into container

for (int i = 0; i < 64; ++i)
xList.Add(new IntBox(i));

// Assuming Data Grid was created via wizard
dataGrid1.DataSource = xList;
}

public class IntBox
{
public IntBox(int val)
{
this.val = val;
}

public int Val
{
get
{
return val;
}
set
{
val = value;
}
}

private int val;
}

Erik
 
Okay. Thanks

I saw some examples on Data Grid and class properties. In your example, I believe the Data Grid will name the column "Val" as it is the property name

Kuphryn
 

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

Back
Top