Hello,
I have a WinForms industrial application running on windows 7 on a touch screen. The users need to select from a drop down with about 50 items. It proves to be a hard task with a standard MS ComboBox control. The scrollbar itself is too narrow, and the users can not relibly touch the up and down arrows or the scroll bar itself with their fingers.
So I started looking for a custom combo box, but I could not find any with a customizable scroll bar width.
So, here is a question - is it possible to change the width of the scrollbar of the UltraComboEditor? I am using NetAdvantage 12.1 Win CLR2x.
And if not, is there any alternative way of easily selecting from a long list on a touch screen.
Any help will be appreciated.
We added the ability to control the ScrollBar with via a property setting in v12.2. So if you don't want to use a CreationFilter, you might want to consider upgrading.
Mike, thanks for the advise.
I downloaded and installed version 2012.2.
Now the problem is that after I ran the Toolbox utility I still do not have 2012.2 in the toolbox. It exists for the CSharp templates, but I am working with a VB project, and it is not there.
From the dos-prompt window I see that the utility did not report anything about VB templates (see below).
Do I have to do anything extra to get 2012.2 objects in my VB projects Toolbox?
Beginning to process VS v10.0
Getting Type for ProgID: VisualStudio.DTE.10.0
Attemping to get CSharp project template
Successfully got CSharp project template
Getting Toolbox
Hi Georgi,
your sample works well as a sample.
To make it useful for me, I had to translate it to vb, and make the width of the scroll bar variable.
First, the original sample falls apart when I try to change the scroll bar width from hardcoded 50 to 100.
Second, my vb version does not work properly :-( .
Could you please take a look at the vb project I attached.
Thanks,
Helen
Hi Helen,
I think Georgi's sample code is a little overcomplicated. Here's a much simpler version of the CreationFilter in VB:
Public Class ScrollbarUIElementCreationFilter : Implements IUIElementCreationFilter Private _scrollBarWidth As Integer Public Sub New(ByVal scrollBarWidth As Integer) _scrollBarWidth = scrollBarWidth End Sub Public Sub AfterCreateChildElements(ByVal parent As Infragistics.Win.UIElement) Implements Infragistics.Win.IUIElementCreationFilter.AfterCreateChildElements If TypeOf parent Is ValueListDropDownUIElement Then For Each element As UIElement In parent.ChildElements If TypeOf element Is ValueListItemContainerUIElement Then element.Rect = New Rectangle(element.Rect.X, element.Rect.Y, parent.Rect.Width - Me._scrollBarWidth, element.Rect.Height) ElseIf TypeOf element Is ScrollBarUIElement Then element.Rect = New Rectangle(parent.Rect.Right - Me._scrollBarWidth, element.Rect.Y, Me._scrollBarWidth, element.Rect.Height) End If Next End If End Sub Public Function BeforeCreateChildElements(ByVal parent As Infragistics.Win.UIElement) As Boolean Implements Infragistics.Win.IUIElementCreationFilter.BeforeCreateChildElements Return False End FunctionEnd Class
I also changed it so that the constructor takes in the width you want the scrollbars to be, not the width of the remaining area.
Hi Mike,
thank you for your help.
The reason Georgi's sample is so complicated is because I asked how to get up and down buttons to be taller - see his image above.
With the code you kindly provided, the up and down buttons are even shorter than normal - see the image I attached.
My users are used to poke at the up and down buttons, and it is hard to educate them as they work three shifts and mostly computer illiterate.
I would appretiate your help in this.
Helen.
here is a larger image of the combo box.
Okay, then you have to rearrange some other elements, too.
Public Sub AfterCreateChildElements(ByVal parent As Infragistics.Win.UIElement) Implements Infragistics.Win.IUIElementCreationFilter.AfterCreateChildElements If TypeOf parent Is ValueListDropDownUIElement Then For Each element As UIElement In parent.ChildElements If TypeOf element Is ValueListItemContainerUIElement Then element.Rect = New Rectangle(element.Rect.X, element.Rect.Y, parent.Rect.Width - Me._scrollBarWidth, element.Rect.Height) ElseIf TypeOf element Is ScrollBarUIElement Then element.Rect = New Rectangle(parent.Rect.Right - Me._scrollBarWidth, element.Rect.Y, Me._scrollBarWidth, element.Rect.Height) End If Next End If If TypeOf parent Is ScrollBarUIElement Then For Each element As UIElement In parent.ChildElements If TypeOf element Is ScrollButtonUIElement Then Dim scrollButtonUIElement As ScrollButtonUIElement = DirectCast(element, ScrollButtonUIElement) If scrollButtonUIElement.ScrollButtonType = ScrollButton.Up Then element.Rect = New Rectangle(element.Rect.X, element.Rect.Y, element.Rect.Width, Me._buttonHeight) ElseIf scrollButtonUIElement.ScrollButtonType = ScrollButton.Down Then element.Rect = New Rectangle(element.Rect.X, parent.Rect.Bottom - Me._buttonHeight, element.Rect.Width, Me._buttonHeight) End If ElseIf TypeOf element Is ScrollTrackUIElement Then element.Rect = New Rectangle(element.Rect.X, parent.Rect.Top + Me._buttonHeight, element.Rect.Width, parent.Rect.Height - (Me._buttonHeight * 2)) End If Next End If End Sub
Mike,
thank you very very much for your help!
Your code works beautifully!
In case anyone wants the complete code, I attached the solution.