3D-kreativ
3D-kreativ

Reputation: 9309

ListBox and CustomTabOffsets.Add

I have created a listBox in a form and I'm trying to find a way to add things like name, phonenumber, city in rows but with each name, phonenumber and city i columns. After some searching I found the CustomTabOffsets.Add, but I don't get it how this work and I can't find any tutorial that explain how this work. Is there anyone here that can help me understand this? I guess there is better options for this, but listBoxs is a must in this task. Thanks!

In my UpdateGUI method I only have this to add a name to the listBox

lstSeats.Items.Add(inName);

Upvotes: 0

Views: 1049

Answers (2)

Slai
Slai

Reputation: 22876

A bit too late, but - how to make more than 2 column's in ListBox using C#?

lstSeats.CustomTabOffsets.Add(12); // "The integers represent the number of quarters of the average character width for the font that is selected into the list box." 
lstSeats.UseCustomTabOffsets = true;
lstSeats.Items.Add("a\tb); // tab character between the items

The custom tab offset integers are quarter of the average character width for the selected font https://support.microsoft.com/en-us/kb/318601

Upvotes: 0

PraveenVenu
PraveenVenu

Reputation: 8337

You need to use ListView for this. Not ListBox

ListViewItem lvi = new ListViewItem();
lvi.SubItems.Add("SubItem");
listView1.Items.Add(lvi);

Upvotes: 1

Related Questions