macro substitution in C#

  • Thread starter Thread starter Ehab Aziz
  • Start date Start date
E

Ehab Aziz

Dear all,
Please can I make my listbox in a variable manner?
I have 3 listboxes and I want to make the number for listbox is a variable ?
I need to display an 2d-array in 3 listboxes .

for (int k = 0; k != array_cols; k++)
{
for (int i = 0; i != array_rows; i++)
{
arraytimes[i, j] = Multi;
Multi = Multi * 10;
listBox($k).Items.Add(arraytimes[i, k]);
}
}
 
Please can I make my listbox in a variable manner?
I have 3 listboxes and I want to make the number for listbox is a variable ?
I need to display an 2d-array in 3 listboxes .

for (int k = 0; k != array_cols; k++)
{
for (int i = 0; i != array_rows; i++)
{
arraytimes[i, j] = Multi;
Multi = Multi * 10;
listBox($k).Items.Add(arraytimes[i, k]);
}
}

You can have an array or collection of ListBox.

Arne
 
Dear all,

Please can I make my listbox in a variable manner?

I have 3 listboxes and I want to make the number for listbox is a variable ?

I need to display an 2d-array in 3 listboxes .



for (int k = 0; k != array_cols; k++)

{

for (int i = 0; i != array_rows; i++)

{

arraytimes[i, j] = Multi;

Multi = Multi * 10;

listBox($k).Items.Add(arraytimes[i, k]);

}

}

Have you considered a ListBox that binds to generic Lists as the datasource? This design might be more efficient that a ListBox with variables that binds to an array.

List<dynamic> dynList = new List<dynamic>() {
new {Id = 1, Name = "Elevator", Company="Vertical Pop" },
new {Id = 2, Name = "Stairs", Company="Fitness" }
};

listBox.DataSource = dynList;
listBox.DisplayMember = "Name";
listBox.ValueMember = "Id";


C# may not support a generic ListBox in a data template because the ListBox represents a data object that binds to specific data.
 
Back
Top