Monday, August 31, 2015

Variable or Dynamic ListBox

A ListBox can implement generics for a dynamic set of columns and rows.  Here's how:

http://www.hightechtalks.com/csharp/

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 than 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";


No comments:

Post a Comment