Page 1 of 1

ListBox Horizontal ScrollBar

Posted: Fri Aug 24, 2012 1:15 pm
by MarkTX
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

Re: ListBox Horizontal ScrollBar

Posted: Fri Aug 24, 2012 1:59 pm
by mark.monroe
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.

Re: ListBox Horizontal ScrollBar

Posted: Tue Aug 28, 2012 7:54 am
by mark.monroe
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

Re: ListBox Horizontal ScrollBar

Posted: Mon Feb 04, 2013 11:07 am
by wlederer
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?

Re: ListBox Horizontal ScrollBar

Posted: Tue Feb 05, 2013 5:33 pm
by Patrick Hall
wlederer wrote:Tried to reproduce it. Added button to check the internal memory:
...
string[] filePaths=Directory.GetFiles("\\FlashDrives\\Project\\Project Files","*.*");
...

What is wrong?
So long as you are testing deployed to HMI and not Run/Simulate on PC then...
"\\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

Re: ListBox Horizontal ScrollBar

Posted: Wed Feb 06, 2013 2:15 am
by wlederer
Thank You Patrick. Works fine now.
Regards, Waldemar