ListBox Horizontal ScrollBar

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
MarkTX
Posts: 9
Joined: Fri Dec 30, 2011 11:03 am

ListBox Horizontal ScrollBar

Post 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

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: ListBox Horizontal ScrollBar

Post 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.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: ListBox Horizontal ScrollBar

Post 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
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

wlederer
Posts: 175
Joined: Fri Jan 27, 2012 4:20 am

Re: ListBox Horizontal ScrollBar

Post 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?

Patrick Hall
Posts: 22
Joined: Fri May 25, 2012 7:44 am
Location: Charlotte, NC. USA

Re: ListBox Horizontal ScrollBar

Post 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
Best Regards,
Patrick Hall

wlederer
Posts: 175
Joined: Fri Jan 27, 2012 4:20 am

Re: ListBox Horizontal ScrollBar

Post by wlederer »

Thank You Patrick. Works fine now.
Regards, Waldemar

Post Reply