Hello,
I am using the following code to programmatically add items to a ListBox control:
string[] filePaths = Directory.GetFiles("\\FlashDrive\\Project\\Project Files", "*.pdf");
foreach (string filePath in filePaths)
{
myListBox.Items.Add(Path.GetFileName(filePath));
}
When I add items this way, the horizontal scrollbar never appears on the ListBox control, even when the filenames are too long to display in the space available.
However, if I add items from within the IDE, using the "Configure Texts" button, the scrollbar appears as soon a text is too long to fit.
Shouldn't the scrollbar also appear when I add items programmatically? Is this a known issue? And is there a workaround?
I am using iX 2.0 and OS v1.09 (v1.04) on a QTerm-A12.
Thanks
ListBox Horizontal ScrollBar
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: ListBox Horizontal ScrollBar
I can reproduce your problem. There doesn't appear to be any way to add a horizontal scroll bar to the listbox. I'll email the developers and ask.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: ListBox Horizontal ScrollBar
Apparently .NET Windows CF scrollbars do not support the horizontal scroll bar. There is a link below that might work as a workaround. We have not tried it out however.
http://www.pcreview.co.uk/forums/listbox-horizontal-scroll-bar-t1868518.html
http://www.pcreview.co.uk/forums/listbox-horizontal-scroll-bar-t1868518.html
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: ListBox Horizontal ScrollBar
Tried to reproduce it. Added button to check the internal memory:
void GetFiles_button_Click(System.Object sender, System.EventArgs e)
{
string[] filePaths=Directory.GetFiles("\\FlashDrives\\Project\\Project Files","*.*");
foreach (string filePath in filePaths)
{
ListBox1.Items.Add(Path.GetFileName(filePath));
}
}
Did not work. After pressing the button the HMI restarted.
Then I added another button to check SD card:
void GetFiles_SD_button_Click(System.Object sender, System.EventArgs e)
{
string[] filePaths=Directory.GetFiles("\\Storage Card","*.*");
foreach (string filePath in filePaths)
{
ListBox1.Items.Add(Path.GetFileName(filePath));
}
}
It worked fine. All files were shown. What is wrong?
void GetFiles_button_Click(System.Object sender, System.EventArgs e)
{
string[] filePaths=Directory.GetFiles("\\FlashDrives\\Project\\Project Files","*.*");
foreach (string filePath in filePaths)
{
ListBox1.Items.Add(Path.GetFileName(filePath));
}
}
Did not work. After pressing the button the HMI restarted.
Then I added another button to check SD card:
void GetFiles_SD_button_Click(System.Object sender, System.EventArgs e)
{
string[] filePaths=Directory.GetFiles("\\Storage Card","*.*");
foreach (string filePath in filePaths)
{
ListBox1.Items.Add(Path.GetFileName(filePath));
}
}
It worked fine. All files were shown. What is wrong?
-
- Posts: 22
- Joined: Fri May 25, 2012 7:44 am
- Location: Charlotte, NC. USA
Re: ListBox Horizontal ScrollBar
So long as you are testing deployed to HMI and not Run/Simulate on PC then...wlederer wrote:Tried to reproduce it. Added button to check the internal memory:
...
string[] filePaths=Directory.GetFiles("\\FlashDrives\\Project\\Project Files","*.*");
...
What is wrong?
"\\FlashDrive\\Project\\Project Files" is probably the path you wanted.
"\\FlashDrives\\Project\\Project Files" is what you had.
The HMI rebooted because of an unhandled exception. Try/Catch is always wise decision.
Directory.Exists(path); [ or File.Exists(path); ] where necessary would let you test and conditionally execute code or alert the operator accordingly.
Best Regards
Best Regards,
Patrick Hall
Patrick Hall
Re: ListBox Horizontal ScrollBar
Thank You Patrick. Works fine now.
Regards, Waldemar
Regards, Waldemar