Assign data to an item in a list? - vb.net

I've set up a list that shows all available fonts. The issue I am having is assigning the actual font "data" to the list item itself so that, when clicked, it will apply that font to the textbox.
How would I go about doing this?
(I'm entirely new to this)

You don't need to, in your case. But if I interpret your question correctly..
What you can do is something like this:
myTextBox.Font = New Font(myListBox.SelectedItem, myTextBox.Font.Size)
This way, you'll be able to assign the font to the textbox based on your listbox's selected item, provided the listbox item IS the name of the font.

Related

combobox properties to allow user to type text in it and let it filter by text entered

I have a combobox where I'll need to allow user to search by text and be able to select that value from the list. So what I'm currently doing is, on CBO_KeyPress, I open the drop down.
Me.cboNames.DroppedDown = True
I set the property of the cbo...
AutoCompleteMode=SuggestAppend
DropDownStyle = DropDown
AutoCompleteSource=ListItems
Everything works beautifully except for one issue. As it stands, i have items in the drop down where the width is significantly wider than the combobox - I have a function that adjusts the DropDownWith to longest string in the list of items. My concern is that while this helps user search for correct item, it's width is only as wide as the combobox. Is there a way to adjust this?
My only other option is to not use AutoCompleteSource=ListItems and instead simply open the dropDown programmatically on KeyPress or something. In this case, it doesn't do as good of a job of filtering the items. AutoCompleteSource does it beautifully but the width issue does not make it look right.
EDIT : Plutonix - here's what I did. I changed AutoCompleteSource=None. On CboName_KeyPress I open dropdown programmatically. Now I type in text, see image below....
It doesn't find text 100% of the time as you can see. AutoCompleteSource narrows it down and only shows you the items that begin with the same text as typed by user but the width is the issue. It actually looks much better with AutoCompleteSource because if they type in text that's not in the list of items then it shows nothing - and user known it's not in the list.
Users tab into the filed and start typing text. They don't open it. That's why they want this to be updated like that. I want them to see the items as they type in.

Difference between Combobox properties SelText and Text?

I don't quite understand the differences between the combobox properties SelText and Text.
If I want to send the content of a combobox as a parameter to another procedure, should I send .text or .selText?
If I want to make enter text into a combobox using a macro, should I write the text in .selText or .Text?
The difference is really given in the name (SelText vs. Text) where Sel stands for Selected. One is used to return or modify the selected text (i.e. SelText) and the other is used to return or modify the entire text (i.e. Text).
If no text is selected in the ComboBox then they return and modify the same value.
I suspect you want to use Text unless you are specifically interested in the selected text.
This appears to be consistent for an ActiveX control on a Worksheet or for a control on a User Form.

Word: remove page from multipage userform

I want, depending of the previous choice from the user just let some tab's being seen.
Once i am new in VBA, i start showing all the tab's and after the choice from the user, i remove the tab's that i don't want. For that i am using this line of code
MultiPage1.Pages.Remove "name of the tab"
The problem is, if i don't have the same CAPTION and the NAME field of the tab the tab is not remove.
If anyone have a diferent solution for this or another away to remove without have to change the caption for the same name of NAME field i would be thankful.
Thanks
You can give a page of a multi-page control a different name from the caption in the Properties Window. You can access it from the View menu.
I've highlighed the name of the control in yellow and the caption in aqua.
If the captions are unique, you could use a Select Case statement to get the name, based on the caption. Are users actually typing in the caption of the tabs they want, or selecting from check boxes? In either case, the captions would have to be unique, so you could do something like:
Select Case True
Case Check1.Value
MultiPage1.Pages.Remove Pages("kp").Index
Case Check2.Value
MultiPage1.Pages.Remove Pages("jp").Index
End Select
That's a bit rough, but is that the general idea?

How would you make the text in a checkbox cell be able to be edited?

How would you make the text in a check box cell able to be edited like in a text cell instead of it just checking the Checkbox? The thing is that the Checkbox is Boolean in the Core Data Model and the Text is a String, so I don't know how I would make this work.
Have two columns: One with a checkbox cell and the other with a text cell, each bound to the appropriate property of your model objects.
Why use checkbox? The checkbox is designed to have two values only as you say. Therefore, you can try other controls, such as input area and so on. What I mean is that you can't make the rectangle to roll because it can't roll at all, right?

Pushing a list of colors into colordialog.customcolors

I have a list of colors i.e.: "1323523, 12342, 2354, 356234, 234234"
Each of these numbers stand for a color. I would like it so that when there is colordialog.showdialog, this list of colors shows up in the colordialog custom boxes.
this is how i am doing it currently, but for some reason the customcolors are not being added. i know for a fact that my array is good because i checked it.
Dim numberStrings = My.Settings.mytext1.Split(","c).Select(Function(x) x.Trim())
ColorDialog1.CustomColors = numberStrings.Select(Function(x) CInt(x)).ToArray()
Here is the documentation on the CustomColors property.
http://msdn.microsoft.com/en-us/library/system.windows.forms.colordialog.customcolors.aspx