TabControl
I am trying to create a quiz with tabs for each question. I want to prevent the user from clicking the above tabs to navigate and instead can only press the next button which moves onto the next tab.
I tried setting the enabled as false and then setting enabled as true inside the next button but that does not seem to work.
Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
TabControl1.SelectTab(1)
End Sub
This is the piece of code which moves onto the next tab. This works fine when enabled is set to true
Related
When i login into my application and i get to the menu form, after the form triggers the form.shown after 1 second timer i start an update procedure.
This procedure calls another form which is on top the menu form, and does certain things.
This update form can also be called from a button that is on the menu form.
The problem here is when i call this form from the button the taskbar is hidden and also the menu form which is at the back is unclickable(I set my application to be full screen so taskbar is not visible). When the update form opens from the timer the taskbar appears, and the menu form which is at the back is clickable, and the user can click buttons from the parent form.
I tried setting focus on the update form after is loaded from the processes of windows but it didn't change anything.
I dont want to show the taskbar nor have clickable parent form.
Any idea why is this happening and how can i fix it?
Here is how i call my form from timer and from the button:
Private Sub TimerDelayedStart_Tick(ByVal sender As Object, ByVal e As Timers.ElapsedEventArgs)
TimerDelayedStart.Stop()
LoadUpdateDatabase()
End Sub
Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click
LoadUpdateDatabase()
End Sub
Private Sub LoadUpdateDatabase()
Try
fUpdateDatabase = New frmUpdateDatabase
With fUpdateDatabase
.ShowDialog()
Cursor = Cursors.Default
End With
Catch ex As Exception
End Try
End Sub
I have a button on my form that I would like to hide permanently if the box is checked. In other words, if the user checks the box, the next time the form shows up, the button should not show up.
I would think that I have to capture the check event on the main form load event and store that somehow, but I am not sure how to that.
I wrote the following, but when the forms loads again, the button shows up.
Private Sub hideMe_CheckedChanged(sender As Object, e As EventArgs) Handles hideMe.CheckedChanged
If hideMe.Checked = True Then
frmRegistration.Show()
hideMe.Enabled = False
End If
End Sub
You need to save something as a setting or such and reload it each time the app starts (guessing at names and functionality):
Form Load maybe:
If My.Settings.IsRegistered = True Then
btnRegister.Visible = False
chkSomething.Checked = True
End If
I have a winform that I use to navigate through my excel workbook. The form opens on the Workbook Open event. All works fine, but I just noticed that if my application is open and I open any other, say IE, my winform remains on top and does not hide. Is there a way to tell my form to hide when my workbook or the application lose focus?
I have searched MSDN and the web and could not really find anything?
Private Sub NavigationForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'This procedure runs when the form loads. The procedure displays
'the form on the upper left hand corner of the main screen.
'It also disables and hids the btnHideForm button.
Me.Location = New Point(0, 0)
With btnHideForm
.Visible = True
.Enabled = True
End With
End Sub
Public Class ThisWorkbook
Private Sub ThisWorkbook_Startup() Handles Me.Startup
Dim navForm As New frmNavigation
navForm.Show()
End Sub
This is the code running on form load and on the workbook open
Okay, I am having a bit of trouble here. I am creating a log in window for an application, but I am trying to get the application to automatically log in (i.e. perform the functions that happen when the user logs in) when it starts, without showing the log in screen, if the settings already have a stored email and password. I have a notification System Tray Icon that shows when the app is running, and when the form is not visible, a balloon notification pops up so the user knows that it is still running, and click on the icon to open the log in screen.
Take a look at the following code. I know that this If Not event is being called and working correctly, because it performs everything inside the statement EXCEPT hiding the form. Why does it not change to invisible? I also tried Me.Hide, and same issue. The Balloon Notification pops up, the text boxes fill with the previously stored data...but the form stays visible...
Private Sub RadFrmLogin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Checks settings to see if email and password have already been stored and enters them into text fields, proceeds to automatically update access list
If Not String.IsNullOrEmpty(My.Settings.Email) And Not String.IsNullOrEmpty(My.Settings.Password) Then
TxtEmail.Text = My.Settings.Email
TxtPassword.Text = My.Settings.Password
Me.Visible = False
'Displays Balloon Tip
ntfySystemTrayIcon.ShowBalloonTip(800)
End If
End Sub
As an added note, I added a test button to hide the form, and it works perfectly:
Private Sub BtnHide_Click(sender As Object, e As EventArgs) Handles BtnHide.Click
'Hides form(for testing notification tray icon and balloon tip
Me.Visible = False
ntfySystemTrayIcon.ShowBalloonTip(1000)
End Sub
(removed my stupid default debug instructions since they did not help at all)
Update
okay, so there were similar questions before, take a look here: C#/.NET - WinForms - Instantiate a Form without showing it
short explanation: usually something like form1.show is used, so it is always changed to visible = true after the form_load is finished.
Either use the instructed event form_shown and add the visible=false
or another user recommended to change start properties to minimized and activate to hide program in taskbar. This helps to prevent that annoying flickering. I guess after that you can change the options back.
Update 2 The following seems to work well:
Private _IsVisible As Boolean
Public Property IsVisible() As Boolean
Get
Return _IsVisible
End Get
Set(ByVal value As Boolean)
_IsVisible = value
If _IsVisible Then
Me.WindowState = FormWindowState.Normal
Me.ShowInTaskbar = True
Me.Visible = True
Me.Activate()
Else
Me.WindowState = FormWindowState.Minimized
Me.ShowInTaskbar = False
Me.Visible = False
End If
End Set
End Property
If you want to get rid of the small taskbar flickering, then change the forms property showInTaskbar. When it is changed during the form_load, then there seem to be a short movement at the taskbar.
And to make it perfect, in form.Shown add following code:
Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown
Me.Visible = IsVisible
End Sub
now it is enough to use
IsVisible = False
in form_Load, or if you want to show it
IsVisible = True
Just some ideas:
If all your tasks are completed in the _Load event try just calling End. Of course that would remove your tray icon as well.
Another possibility is to call Me.Visible in the _Shown event. This may cause a flash on the screen. If so perhaps you could position the form off the screen in _Load.
I have a tab in a windows form called Wafer Map that has three sub-tabs. The First sub-tab is the called Map and has a Load and Skip button. I am trying to set the focus on the Wafer sub-tab on the Load button click. This is the following code I have tried to use.
Private Sub Load_Wafer_Layout_Map_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Load_Wafer_Layout_Map.Click
Wafer_Info.Enabled = True
Wafer_Info.Show()
End Sub
The Wafer_Info.Enabled = True is used to enabled all of the controls on the Wafer tab and works properly when the button is clicked. I have tried using .Focus() and .Show() to bring focus to the next tab but I am not have any luck getting to switch. Anyone have any suggestions?
Just set it:
tabControl.SelectedTab = yourTab
On the Tab Controls Tab Pages, just ensure you name the tab you are attempting to reference. Additionally, see MSDN TabControl.SelectedTab
The code that worked for me is Tab_WaferMap.SelectTab(1). Tab_WaferMap is my main tab and the 1 is the index of the sub tab I wanted to show
I came across this thread as i was looking for a solution to my own focus issue. I have a TabControl with many TabPages. Each TabPage is set to auto scroll due to overflowing content. The problem I ran into was the mouse scroll wheel would not function if the TabPage did not have focus. Since there is not an event for each tab click it made setting focus to each TabPage a challenge. It was not hard, but a challenge none the less. So, here is my code (assuming auto scroll true).
On form load sets focus to main TabPage:
Private Sub frmParent_Load(sender As Object, e As System.EventArgs) Handles Me.Load
TabControl1.TabPages(0).Focus()
End Sub
Sets focus to current TabPage by getting the index then setting focus.
This is triggered by TabControl1.SelectedIndexChange event.
Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
Dim intTabIndex As Integer = TabControl1.SelectedIndex
TabControl1.TabPages(intTabIndex).Focus()
End Sub
I hope someone find this useful. It was very useful for me.
Joshua
You can also set the Selected Index of the tab (and sub-tab) using a (zero based) numeric value:
TabParent.SelectedIndex = 3
TabSub.SelectedIndex=2