VB.Net BalloonTipText appears as a black rectangle - vb.net

I have a strange problem, I have created a test form FrmTest. Added a NotifyIcon and added the code shown:
Public Class FrmTest
Private Sub FrmTest_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Sub FormTest_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Click
Call SetBalloonTip()
NotifyIcon1.Visible = True
NotifyIcon1.ShowBalloonTip(30000)
End Sub
Private Sub SetBalloonTip()
NotifyIcon1.Icon = SystemIcons.Exclamation
NotifyIcon1.BalloonTipTitle = "Balloon Tip Title"
NotifyIcon1.BalloonTipText = "Balloon Tip Text."
NotifyIcon1.BalloonTipIcon = ToolTipIcon.Error
End Sub
End Class
When I click to make the balloon appear I get this:
I must be doing something obviously wrong but I am stumped!

There is nothing to say you did well...
That is what a balloon Tip looks like on Windows 10. Best of luck.

Related

Better way to accomplish simple task in VB.Net

So, I have a small test for school where I need to DISABLE three radio buttons which are in a panel in the least amount of possible code WHILE the contents of two text boxes are empty. As soon as both textboxes are filled, I enable the panel.
The below solution obviously works with one single text box, but what happens with two?
I know I can override each button KeyPress and check both text boxes at the same time. But I wanted to go fancy. The problem is I think there is no way I can solve this problem like this.
Or is it?
Public Class Form1
Public Sub vacios(sender As Object, e As System.Windows.Forms.KeyPressEventArgs)
Panel1.Enabled = (sender.Text <> "")
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
AddHandler txtNombre.KeyPress, AddressOf vacios
AddHandler txtApellido.KeyPress, AddressOf vacios
End Sub
End Class
Note - I know I can do this But I wanted to be fancy.
Public Class Form1
Private Sub txtNombre_TextChanged(sender As Object, e As EventArgs) Handles txtNombre.TextChanged
Panel1.Enabled = (txtNombre.Text <> "" And txtApellido.Text <> "")
End Sub
Private Sub txtApellido_TextChanged(sender As Object, e As EventArgs) Handles txtApellido.TextChanged
Panel1.Enabled = (txtNombre.Text <> "" And txtApellido.Text <> "")
End Sub
End Class
in VB you can have multiple handles for the same sub just by adding "Handles Object1.Event,Object2.Event ..." at the end.
here an example of what i would do in this case
Public Class Form1
Private Sub panel1TextBoxes_TextChanged(sender As Object, e As EventArgs) Handles txtApellido.TextChanged,txtNombre.TextChanged
Panel1.Enabled = (txtNombre.Text <> String.Empty And txtApellido.Text <> String.Empty)
End Sub
End Class

Custom tray panel in VB.NET

i need to create system tray "panel" like Windows Media Player.
(not icon only, but complette form with buttons, images, etc.)
Here is wmp screenshot:
Is it possible in VB.NET & Win 10?
Thanks and sorry for my english.. :)
You actually can do kind of a "tray panel", and it isn't quite difficult. Just create a Form Object and set its FormBorderStyle property to None, which will allow you to create your custom border. Then, do the following:
Public Class Form1
Public Timer1 As New Timer
Private Sub Form1_Load(sender as Object, e as Eventargs) Handles MyBase.Load
Timer1.Interval = 1
End Sub
Private Sub Form1_MouseDown(sender as Object, e as MouseEventargs)
Timer1.Start()
End Sub
Private Sub Form1_MouseUp(sender as Object, e as MouseEventargs)
Timer1.Stop()
End Sub
Private Sub Timer1_Tick(sender as Object, e as Eventargs)
Me.Location = New Point(Me.Cursor.Position.X - (Me.Cursor.Position.X - Me.Location.X), Me.Cursor.Position.Y - (Me.Cursor.Position.Y - Me.Location.Y))
End Sub
End Class
Once you've done that (I'm not sure it will work directly, try a bit and it should), enjoy designing the GUI... ;-)
Hope this helps and by the way, your english is better than you think!

Print Progress bar value to textbox

I'm trying to print a progressbar's percentage to a textbox. When ever I run my program, nothing appears in the textbox. This is my code:
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
ProgressBar1.Maximum = TextBox1.Text
End Sub
Help is very appreciated! Thank you.
Here is some code that i have written up for you to have a look at, it should lead you in the right direction and help you on your way :)
Imports System.ComponentModel
Public Class Form1
''This will display the information to the textbox and will also load a progressbar(you can change it to something else beside a textbox too eg label, windows form title and so on).
Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
TextBox1.Text = e.ProgressPercentage & "%"
ProgressBar1.Value = e.ProgressPercentage
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
''This is make the backgroundworker start at load up(change it to a button if need be
CheckForIllegalCrossThreadCalls = False
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
''This is the example that i created to show you how to set a task.
For i = 0 To 10000
TextBox1.Text = i
BackgroundWorker1.ReportProgress(i)
System.Threading.Thread.Sleep(500)
Next
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
''once the task is complete it will show a messagebox and reset the progressbars value to 0 so its not full when the task is compelete.
MessageBox.Show("Completed")
ProgressBar1.Value = 0
End Sub
End Class
Let me know how you go, i live in a country where i cant access the website link that you posted.Happy Coding
UPDATE: do check out the backgroundworkers on google, there are a lot of tutorials to help you :)

result of a modal form in vb.net

I create a form 'frmX' and i call it as a modal form :
res = frmX.ShowDialog()
This form has 3 buttons, Abort(3), Retry(4) and Ignore(5), but when the form opens, all the buttons on the first click return 2.
I don't know why this occurs--all of the buttons has their property DialogResult right.
*Private Sub btnIgnorar_Click(sender As Object, e As EventArgs) Handles btnIgnorar.Click
btnIgnorar.DialogResult = DialogResult.Ignore
End Sub
Private Sub btnAbortar_Click(sender As Object, e As EventArgs) Handles btnAbortar.Click
btnAbortar.DialogResult = DialogResult.Abort
End Sub
Private Sub btnReintentar_Click(sender As Object, e As EventArgs) Handles btnReintentar.Click
btnReintentar.DialogResult = DialogResult.Retry
End Sub*
Can someone help me?
Could do with seeing a bit more context, but the following should do what I think you want:
Private Sub btnIgnorar_Click(sender As Object, e As EventArgs) Handles btnIgnorar.Click
DialogResult = DialogResult.Ignore
Close
End Sub
This will close the dialog and return the associated result code to the caller. As to the original code, it seems a bit strange setting the values in the buttons click handlers?
The error comes from the fact that you set the DialogResult of the buttons. You must set the DialogResult of the form !
You actually have more than one option.
Option 1 : Set the Form.DialogResult
Private Sub btnIgnorar_Click(sender As Object, e As EventArgs) Handles btnIgnorar.Click
Me.DialogResult = DialogResult.Ignore
End Sub
Private Sub btnAbortar_Click(sender As Object, e As EventArgs) Handles btnAbortar.Click
Me.DialogResult = DialogResult.Abort
End Sub
Private Sub btnReintentar_Click(sender As Object, e As EventArgs) Handles btnReintentar.Click
Me.DialogResult = DialogResult.Retry
End Sub
Option 2 : Set the Button.DialogResult
Public Sub New()
InitializeComponents()
'Your init code here
'...
'By setting the buttons DialogResults, you don't even have to handle the click events
btnIgnorar.DialogResult = DialogResult.Ignore
btnAbortar.DialogResult = DialogResult.Abort
btnReintentar.DialogResult = DialogResult.Retry
End Sub
'However, if you need to do some stuff before closing the form, you can
Private Sub btnAbortar_Click(sender As Object, e As EventArgs) Handles btnAbortar.Click
'Do some stuff
'You don't need the following line, as it will be done implicitly
'Me.DialogResult = DialogResult.Abort
End Sub

Disable Tab Control when pressing Button VB.NET

I would like to ask if how could possibly disable tabs in tabcontrol.
This is what the codes looks like when disable:
Public Sub TabControl1_Selecting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Selecting
If e.TabPageIndex = 3 Then
e.Cancel = True
End If
End Sub
This code only disable while you load the form
I was trying to convert a code from c# however it doesn't work as I expected.
See this code:
Public Sub EnableTabs(ByVal Page As TabPage, ByVal bolFlag As Boolean)
EnableControls(Page.Controls, bolFlag)
End Sub
Private Sub EnableControls(ByVal Ctrls As Control.ControlCollection, ByVal bolFlag As Boolean)
For Each Ctrl As Control In Ctrls
Ctrl.Enabled = bolFlag
EnableControls(Ctrl.Controls, bolFlag)
Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'I have problems with this line
EnableTabs(TabControl1.TabPages(TabControl1.SelectedIndex) = 0, False)
End Sub
Is there anyway that I could possibly disable a tab while clicking a button?
Let me know!
Thanks,
Regards,
Alvin
Try this:
Private Sub Button_Click( sender As Object, e As EventArgs) Handles Button.Click
Dim tabPage As TabPage
For Each tabPage In TabControl1.TabPages
If tabPage.Text ="TabPage1"
tabPage.Enabled =False
End If
Next
End Sub
or
Private Sub Button1_Click( sender As Object, e As EventArgs) Handles Button1.Click
TabControl1.TabPages(0).Enabled =false
End Sub
Yet another answer.
At some point if you want to disable a tab - use this code at the appropriate point
TabControl1.TabPages(x).Enabled = False
Where x is the zero-based index of the tab page you want to disable.
When the user clicks on a TabPage, the Selecting event fires for the whole control. Using the e eventargs parameter you can see the index of the TabPage being selected. The code in this event checks to see if it is disabled and if so, cancels the tab click.
Private Sub TabControl1_Selecting(sender As Object, e As TabControlCancelEventArgs) Handles TabControl1.Selecting
If e.TabPage.Enabled = False Then
e.Cancel = True
End If
End Sub
I already answered it. Anyhow, I would like to share it for you guys.
I just change the code from:
EnableTabs(TabControl1.TabPages(TabControl1.SelectedIndex) = 0, False)
to:
EnableTabs(TabControl1.TabPages(1), False)
This code only the contain of tab not by disable while selecting/clicking the tab header. I think I just use this one for now. If you have other source of code that is useful enough. Just leave on the answer section below. I loved to hear them all.
Thanks anyway.
Regards,
Alvin
I have already my own answer based on it. And I used this code right now, for example I have 3 tabs with 0-2 index respectively.
Public Sub Tab0Flag As Boolean
Public Sub Tab1Flag As Boolean
Public Sub Tab2Flag As Boolean
Public Sub TabControl1_Selecting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Selecting
If e.TabPageIndex = 0 Then
e.Cancel = Tab0Flag
End If
If e.TabPageIndex = 1 Then
e.Cancel = Tab1Flag
End If
If e.TabPageIndex = 2 Then
e.Cancel = Tab2Flag
End If
End Sub
Private Sub EnableTabs(ByVal Tab0 As Boolean, ByVal Tab1 As Boolean, ByVal Tab2 As Boolean)
Tab0Flag = Tab0
Tab1Flag = Tab1
Tab2Flag = Tab2
End Sub
Private Sub frmG_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'I'll Only Disable the 2nd tab
EnableTabs(False, True, False)
End Sub