Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using VS2010 and its .NET Framework 4, for Win Application.
I need to make a couple of Listbox Controls that are loading a couple List<strings> in them.
- The problem is how do I update every other listbox when I sort 1 listbox?
Lets say I have only 10 Listboxes. Everything is INLINE with the 1st listbox as default. The order of the 1st listbox is represented in the rest of the other listboxes. When I sort the 4th listbox, every line in this specific list will sort BUT HOW I keep the same INLINE position of the other listboxes?

What I have tried:

For example, this is the database text that it will process and split into each List<string>:
Name_\Amps\Vol\_Mark\_Type_____\Pack
SI2302\2.5A\20V\A2SHB\N-channel\SOT-23
SI2303\1.4A\30V\A3SHB\P-channel\SOT-23
SI2305\3.5A\08V\A5SHB\P-channel\SOT-23

Everything is sorted by Name(1st listbox) by default, and is INLINE with it.
But when I sort by Mark, every other listbox must keep the same alignment.

My question to you is:
1- is it already a component that is keeping this alignment for me in VS2010?
2- what is the logic or the code to make it from scratch?
I already have an idea but I want to check first with you here.
Thank you.
Posted
Updated 29-Oct-21 2:29am
v2
Comments
BillWoodruff 29-Oct-21 5:13am    
Please define what "INLINE" means; why would you sort a ListBox's contents rather than sort a column in your DataTable, or other structured data source ?

1 solution

In my opinion using separate ListBoxes for showing items that belong together is the wrong approach.
I would use a DataGrid.
When sorting one column all other columns will be in sync.
DataGrid is available for Windows Forms as well as WPF.
 
Share this answer
 
Comments
BillWoodruff 29-Oct-21 5:14am    
+5
TheRealSteveJudge 29-Oct-21 5:24am    
Thank you!
_Q12_ 29-Oct-21 7:12am    
TheRealSteveJudge +5 from me as well. It looks like what I need.
I am playing now with its code. Im looking for tutorials about it as well.
TheRealSteveJudge 29-Oct-21 7:14am    
Thank you!
_Q12_ 29-Oct-21 8:30am    
I have a problem with the auto sorting of this control:
https://i.imgur.com/XbRei7x.jpg[^]
3A should be before 3.5A

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