Select and Show new Tab on control when values in txtbox change, but keep focus on txtbox - vb.net

I'm having this issue that should be pretty easy to solve but I just can't seem to figure it out or find an answer yet. I have the following code:
Public Sub NotifyThatValuesChanged(sender As Object, e As EventArgs)
APIUserForm_MAIN.OnSecurityInputValuesChanged()
APIUserForm_MAIN.MessageSender.TabControl.SelectTab(0)
End Sub
So, I'm rasing events when values within txtboxes change, and one of the things I want to do is change tab focus when these values change, which it is doing...but....I don't want the cursor (or focus) to change to the selected tab. I want the cursor/focus to stay where it is at while this event happens, and for the tab selected on this other control to change from (1) to (0).
Thanks for the help!!!!

I don't think it's 100% possible. Try putting the focus back into the textbox:
Public Sub NotifyThatValuesChanged(sender As Object, e As EventArgs)
APIUserForm_MAIN.OnSecurityInputValuesChanged()
APIUserForm_MAIN.MessageSender.TabControl.SelectTab(0)
TextBox1.Select()
End Sub
If multiple controls are calling this method, you can use the sender parameter:
DirectCast(sender, Control).Select()

Related

Show hourglass cursor application-wide during Load Event while ShowDialog

I have the following code:
Private Sub btnNew_Click(sender As Object, e As EventArgs) Handles btnNew.Click
Dim f As New frmStyle
f.ShowDialog()
End Sub
frmStyle does many things during it's Load event, so it doesn't appear immediately. Instead, it takes around 1 second to show up.
Because of that, I want to show an hourglass cursor during the form's Load event.
In VB6 it was super easy. I could just use "Screen.Cursor = vbHourglass".
Then you could set the cursor back to the default from whereever you wanted, for example at the end of a Form_Load event.
How can this be done in VB.NET now?
I want to show the cursor application-wide, and not for a single control only.
And ALSO (what makes my question unique and NOT answered so far in another question), I need to reset it, but it should be reset at the end of Form_Load (which is NOT the initializing element. Instead the button is the "initializing" element, but I can not set the cursor to default at the end of the button click because ShowDialog is shown modally. This means that the cursor would only be changed back if the form was closed again).
Thank you!

Disable combo box list

I want to disable a combo box dropdown list from showing in VB.NET and then enable it. How can I do this? The default value of the cbo box should be enabled for typing.
Thanks
After Searching for same to disable combo box in vb .net cant find good answer which help...
so i tried some thing like this
1st thing to do while disabling
combobox1.enabled=false
combobox1.beginupdate
2nd thing to do while enabling
combobox1.enabled=true
combobox1.endupdate
its looks simple and i dont found any problem but i have doubt may it effect any excecution speen or other object
I want to disable a combo box dropdown list from showing in VB.NET and then enable it.
Ok, use the .Visible property....
The default value of the cbo box should be enabled for typing
Oh.... then.
The bad news.
You can't.
The good news.
You simply put a textbox on top of the combobox. When the dropdown should be disable, make the combobox invisible and show the textbox.
'Goodbye Combo
Private Sub HideComboButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HideComboButton.Click
comboBox.Visible = False
txtBox.Visible = True
End Sub
'Hello Combo
Private Sub ShowComboButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowComboButton.Click
comboBox.Visible = True
txtBox.Visible = False
End Sub
Try using the Enabled method eg comboBox1.Enabled = False Tellme how that works out for you
Try using dropdownstyle, simple can be used to remove list by manually closing the list in designer, then u can switch between dropdown and simple to achieve what you need.

how to add combobox items in listbox or listview

I want to know what control to be use on my project is it Listview or listbox???. I have a comboBox control on my project what I want to do is when I selected 1 item on my combobox it will automatically add on listbox or listview and when I selected more than 1 item I want to add it on listbox or listview on newline...
Is it simple, please help me to do that in listbox or listview..thanks!
Listbox > Is for viewing too but user can select it
Listview > Is for viewing only, user cannot select also it viewing by five view directly cause it's for viewing only
If your project wanted the list to be viewing from what have been select by Combobox, then you just pick List View, but if you want for viewing also user can select it, better use listbox, so it's up to you.
Also you can know how the Tools work by focus your mouse cursor to the tool, then it will pop up an tooltip that write what the tool for.
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
ListView1.Items.Add(ComboBox1.SelectedIndex)
End Sub
That is the code to viewing in listview for what you select in combobox
For clearing all the item in the Listview or listbox, just write to your form_load
Listview.items.clear
Why i said in form load, cause the list just for viewing, of course every time the form begin to run, it will need blank list, so the best is put in form load
UPDATE
To remove the selected index in listbox
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
ListView Items can be selected a couple of ways In the Properties window for the ListBox the activation property allows an item to be activated by one click or two clicks. Here is an example of how the selected items can be used
If Me.ListView1.SelectedItems.Count = (1) Then
'Declare the selected item
Dim lviSelectedItem As ListViewItem = Me.listView1.SelectedItems(0)
'Now you can use it
lblLabel1.Text = lviSelecetedItem.Text
Else
lblLabel2.Text = "You can make Items selectable by switching CheckBoxes property to True in the Properties windows and using CheckBox event handlers"
End If

how to clear a listview from another form in vb.net

I would like to know, how to clear a list view items from an another form. For instance, I have Form A with a ListView, I would like to clear the Form A ListView Items from Form B. What I tried is, create a function in Form A to clear the listView and call that function from Form B. But it is not working. Please help me to resolve this issue.
Here is a quick and easy way to do so; this removes all items from listbox using a for each...
Private Sub btnClearListView_Click(sender As System.Object, e As System.EventArgs) Handles btnClearListView.Click
For Each I In FormA.ListView1.Items
FormA.ListView1.Items.Remove(I)
Next
End Sub
Thanks!

Showing List of combobox while getting focus (vb.net)

When we click on drop down combobox control in our windows form, it shows the list automatically.
But when we press tab and navigate to that control from keyboard it doesn't shows the list automatically. So in other to show the list automatically on receiving focus what should be done?
Set the DroppedDown property of the combobox equal to true.
Private Sub myComboBox_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles myComboBox.GotFocus
myComboBox.DroppedDown= true
End Sub
I would like to mention on thing here.
I used Enter event to show Drop down list with DroppedDown=true,
But When I type something in text area of combobox and if i leave the area to next control, entered text is lost.
My combobox is databound.