Visual Basic element - vb.net

I'm kind of new at visual basic. I just can't for the life of me figure out how to make this single element. a single line combo box with two scroll bars. For instance if I had the numbers 1-4 loaded into it, it would start displaying 1, I hit the down arrow it displays two etc, but if I hit the up arrow it goes down an index. I can make the combo box to only have one arrow, but I need the rest of the scroll bar. I tried a list box but can't do it where it displays one item at a time. Thanks!

I think you could you use NumericUpDown component.
You could set the increment on properties sectian and it has two arrows up and down.

I think what you're looking for is the NumericUpDown control.

You should go for a numeric control. You can set a min and max value and so on. For numeric options is the way to go.

Related

How can i remove the border between 2 textboxes that are next to each other in order to look as one

Say I have this form of a timer:
https://gyazo.com/ffdae5829005768d53fcb625c6b971b8
The minute textbox and the second/millisecond textbox are next to eachother but there is an obvious line in between them which is the border between both seperate textbox. How do I remove this border to make it look like its just 1 seemless textbox?
While viewing the form in designer mode you can right click one of the textboxes and select Properties. This should open a pane that will permit you to change the BorderStyle property to None. Do this for both textboxes and it will appear seamless.
You can do what NoAlias did but this will not show any border at all. I think you want to make it look like a single textbox right?
I have three other suggestions:
Use a single textbox to show Minute and Second/Millisecond.
Use a label. Set it's background color to the same as textbox background and put it between those textboxes. This will make it look
like it's a single box too.
Do what NoAlias did, and add a RectangleShape around the two textboxes to make it look like a textbox. You can find it in the toolbox under the heading Visual Basic PowerPacks.

Metro App Create Email Address Entry Xaml Control

How do I create a Control to input email addresses, similar to how capturing tags on stackoverflow works?
I am using C# and Xaml.
You will need:
TextBox(to show input area where you can type)
Popup(to show suggestions below TextBox like StackOveflow does)
ItemsControl(it goes into Popup, so you can just have collection of items and they will be displayed, note that ItemsPanel should be probably GridView)
Then you will need custom Button, that will be overlaid top of TextBox once tag has been added. You need to calculate how big is the button(width) and fill TextBox with empty spaces, to advance cursor further.
Also you need to control what keys are being pressed.
The effect you are after is probably that you recognize complete e-mail addresses, and render them in a custom way. I would do this by removing the completed addresses from the textbox, and wrap them in a skinned label (or maybe a custom control with a delete button).
The most straightforward way is to implement the textbox as a DockPanel with a border, suggesting that it is a text box. On the left side of your DockPanel, you have a StackPanel where you stack the completed address controls left-to-right. Then add a textbox with DockStyle=Fill to fill up the remainder of the DockPanel. Once you detect an email address is entered, you remove the characters from the textbox and add a matching control to the StackPanel.
There is probably a way to change the textbox contents without losing focus, otherwise you need to fix this though code.
Good luck!

Best way to select from a list - aren't the two listboxes getting a little old?

How many times have we seen this type of selector:
List Box Selector http://geekswithblogs.net/images/geekswithblogs_net/dotNETvinz/MoveItemsListBox.jpg
I was just about to start creating this in a WinForms app, when I thought that others may have some ideas for doing this better. We need it to sort - so the right hand list will need up/down buttons. But this seems so old school. I love devexpress components, and was thinking of asking them if they would consider adding a component that handles this functionality with a slick UI.
I am thinking that a graphical representation of the objects, and a graphical representation of the listboxes - that would be a more intuitive way to move items around.
Has anyone seen an open source project like this?
If a CheckListBox won't suffice (and it usually will), then the "modern" approach would be to use a ListView or similar component with a "Transfer" column. Render the button inline in that column, one for each row, so that it only takes one click to move an item from one to the other.
You see this everywhere in Vista, usually with hyperlinks as opposed to buttons. Instead of clicking on an item and then choosing an action, you click the action at the item level.
I wouldn't go overboard with slickness as it can impair functionality, but the dual-listbox screen is definitely old-school.
Also, if there's a very large amount of data to manage, it helps to provide a progressive search at the bottom of one or both lists.
I have done this type of selection using (essentially) a single CheckListBox that displays each item as an image. Part of the image looks like a LED, which is on (bright) if the item is selected or off (dark) if it is not selected.
This works well if you have a reasonable amount of data to select from, and also works well in a multi-column format if you can predict that the options will have reasonably similar lengths.
Allow users to drag items in/out of list 2, and also drag to reorder in list2.
(All items dragged out of list2, and dropped anywhere outside the list, get put back into list 1, in their correct place in the list by alphabetical or natural order.)
You can merge the two list boxes into one with the help of groups (LVGF_GROUPID flag): one group for selected and one for not selected.
You can also implement group membership changes with drag-drop between them. This way single drag-drop can move an item into the other group at the appropriate position, saving most/all of the other buttons.
Additionaly the bottom of each group can have one pseudo item with help text (i.e. "Drag items here to...") that is visible only when relevant.

How can I add a horizontal scrollbar to a VBA ListBox

I'd like to add a horizontal scrollbar to a VBA ListBox.
It appears that the built in ListBox does not add a horizontal scrollbar automatically. I have a number of fields whose contents exceed the width of the ListBox and are thus unreadable to the user.
I found this article, however the code fails, due to accessing hwnd of the ListBox (which is apparently not available in VBA). I'd rather not write a native DLL to accomplish this as I suspect there is a better way.
Any idea on how I can add a horizontal scrollbar to a VBA ListBox?
I'm open to the idea of using an alternate control rather than getting it to work with the ListBox specifically.
Did you try ColumnWidths property?
I have listbox with horizontal scroll bar. I just had to add ColumnWidths property.
For example I have
me.Listbox1.Columnwidts ="0.5 in;0.2 in;1.5 in;0.75 in;0.5 in"
Unless I'm missing something, a VBA listbox will automatically gain a horizontal scrollbar if the total of its ColumnWidths property exceeds its own width.
There are no properties I know of that affect this behaviour, i.e. I don't otherwise know how to force or disable display of the horizontal scrollbar.
Access will automatically add a horizontal scrollbar if the column width exceed the width of the listbox. HOWEVER, if you are using multiple columns, the first column cannot be set to 0. You must have at least some value in there, even if it's just 0.1" Hope this helps.
In that article, the only reason it's getting ScaleMode is to set the width of the horizontal scroll bar. You don't have to do that.
SendMessageByNum List1.hwnd, LB_SETHORIZONTALEXTENT, 800, 0
where 800 is the pixel width you want the list box to be able to scroll right to.
You will still need the hWnd. Best bet there is to use an external DLL (written in VB) which can enum through child windows of your process until it finds the windows class for the listbox (you will need to find some way to uniquely identify its parent, such as the window title/text or something). That same DLL could also do the SendMessage call above to set the horizontal text extent (perhaps also it could measure the width of the contained list items).
Handle to he list box can be obtained as follows :-
Dim ListHwnd As Integer
lstboxName.SetFocus
ListHwnd = GetFocus()
Use this ListHwnd as the first parameter to the sendmessage function...
We need to provide the declaration below,Since GetFocus function is not present in VBA by default
Private Declare Function GetFocus Lib "user32" () As Integer
In Visual Studio 2017, you can click on the list box, then go to the properties panel, and then (scroll down to) find the 'HorizontailScrollbar' property. By default this is property is set to false, so you should set it to true.
You know you have set the scroll bar properly when a small triangle appears in the top right corner of the list box.
Hope this helps.

What is the best way for my application to get user input in VB.NET?

My winforms application will display 100 different names, and I will need the user to enter a number 1 through 4 next to each name. I will then store this data.
I know I can use the spreadsheet control, but is there something much simpler that I can use?
Maybe an array of textboxes or a datagrid?
You should be able to use a datagrid and have the first column contain a textbox Item and have a second column display a name. you should also be able to use a listview the same way. Although to be honest you might want a drop down box put in the gridview instead of a text box because with a dropdown/combo box you can make sure they input only a 1-4 because that will be there only options
I would recommend using a DataGrid. This will scale much better than an array of TextBoxes, and should do exactly what you need.
Why not use a numeric up/down control (spinner)?
Something like this would work well:
http://visualbasic.about.com/od/usingvbnet/l/aa082103a.htm
You can embed this in a custom field in a datagrid or repeater if necessary.
You can also just use a combobox:
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.aspx
Depending on what you are using this for, you might also be able to use something like this:
http://www.codeproject.com/KB/miscctrl/cs_star_rating_control.aspx
Then the user can just click the value.
With either of these options at least your user wont have to enter a value manually and you can set bounds in the control instead of having to validate their input. Your last option should be the user entering a number into a textbox really.