DataGrid array

  • Thread starter Thread starter Roy Clemmons
  • Start date Start date
R

Roy Clemmons

Greetings,

I have an array of DataGrid classes. Each DataGrid in the array needs to
handle the SizeChanged event.

How do I dynamically accomplish this using vb.net? In other words, how do I
programmatically set a handler for each DataGrid in the array?

Thanks!
 
Roy,
The example I'm providing is in C# but it should be easily converted to
VB.Net. For example reasons I initialized the array to 2 elements.

private DataGrid[] dg = null;
private void InitDataGrids()
{
dg = new DataGrid[2];

for(int index = 0;index < dg.Length; index++)
{
dg[index].SizeChanged += new System.EventHandler(this.GridSizeChanged);
}
}

private void GridSizeChanged(object sender, EventArgs e)
{

//put code here for size changed event
}

HTH
 
Back
Top