Posted 18 August 2026, 9:09 am EST
How do you add variables to a ListBox?
For i = 0 to 10
Col1 = “AAA” & i
Col2 = “BBB” & i
lstTest.AddItem(Col1;Col2)
Next
Doesn’t work
Forums Home / ComponentOne / WinForms Edition
Posted by: xman0002 on 18 August 2026, 9:09 am EST
Posted 18 August 2026, 9:09 am EST
How do you add variables to a ListBox?
For i = 0 to 10
Col1 = “AAA” & i
Col2 = “BBB” & i
lstTest.AddItem(Col1;Col2)
Next
Doesn’t work
Posted 19 August 2026, 12:28 am EST
Hello,
For clarification, the AddItem method accepts a single string representing the row, where a semicolon is used as the default column separator. You can also customize this separator if needed via the AddItemSeparator property. For more information, refer to https://developer.mescius.com/componentone/docs/win/online-list/listforwinformsaddit
To add multi-column variables in your loop, you can concatenate the variables into a single string using either of the ways specified below:
'Option 1: Direct string interpolation
C1List1.AddItem($"{col1};{col2}")
'Option 2: Concatenating into a string variable
Dim rowText As String = col1 & ";" & col2
C1List1.AddItem(rowText)
We have attached a sample project for your reference.
If you have any further questions or concerns, please let us know!
Best regards,
Vivek Singh
Posted 20 August 2026, 3:08 pm EST
Thanks!
Posted 20 August 2026, 5:41 pm EST
Second Question - How do you set the column widths?
FlexGrid : grdMenu.Cols(0).Width =50 (Works)
ListBox : lstMenu.Cols(0).Width = 50 (Doesn’t Work)
Posted 20 August 2026, 11:23 pm EST
Hello,
C1List supports split presentation, providing the flexibility to resize either the splits or the individual columns within them. You can adjust column widths programmatically as follows:
c1List1.Splits[0].DisplayColumns[0].Width = 250;
For more detailed information on C1List and its related APIs, you can refer to our official documentation: https://developer.mescius.com/componentone/docs/win/online-list/overview
You can also check out our product samples at C:\Users<UserName>\Documents\ComponentOne Samples\WinForms\v4.8\List if you installed the samples via the ComponentOne Control Panel. Alternatively, you can access the same samples on GitHub: https://github.com/GrapeCity/ComponentOne-WinForms-Samples/tree/master/NetFramework/List
We have attached a sample project for your reference. Please take a look, and if you have any other questions or concerns, feel free to let us know!
Best regards,
Vivek Singh