macro substitution in C#

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]);
}
}
 
A

Arne Vajhøj

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
 
K

Kara Hewett

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.
 

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

Top