Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!

I have one listbox with items ( just one item for now )

ListBoxItem1 
   {
X= 200  Y= 205
X= 400  Y= 402
X= 100  Y= 200
X= 250  Y= 250
}


What I have tried:

How can I split it so that it only says:
Code:
X=200  
Y= 205

I'm trying to use it like this:
Code:
Cursor.Position.X = ListBoxItem1.Text
Cursor.Position.Y = ListBoxItem1.Text

Well, of course that's not going to work, but trying to give an example of my destination. I wish the listbox had columns, so I could just select from an invidivual column:
Cursos.Position.X = ListBoxItem1.Column1.Text

Lol, hope you understand what I'm trying to do.
Posted
Updated 27-Aug-20 8:57am
Comments
BillWoodruff 28-Aug-20 4:17am    
The real question here is why you want to hide the "other" data.

1 solution

Quote:
I wish the listbox had columns

Hey! Seems you missed it. It's there: ListBox.MultiColumn Property (System.Windows.Forms) | Microsoft Docs[^]
C#
listBox1.MultiColumn = true;
listBox1.Items.AddRange(new object[] { "Item 1, column 1", "Item 2, column 1", "Item 3, column 1", "Item 4, column 1", "Item 5, column 1", "Item 1, column 2", "Item 2, column 2", "Item 3, column 2" });


Another alternative if you really want some customization to it - Create a new custom control inherited from listbox and have the structure you like/want.
Here an example: Multi Column List Box in C#[^]
 
Share this answer
 
Comments
BillWoodruff 31-Aug-20 1:15am    
+5
Sandeep Mewara 31-Aug-20 1:45am    
Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900