status bar help

  • Thread starter Thread starter K E Senthil Kumar
  • Start date Start date
K

K E Senthil Kumar

Hi,

I am using Vb.Net. I use a frmMain which has a menu and explorer style. On
click of menu or item in explorer, other forms are activated. The frmMain
has a Status bar control. The events of the other forms are also to be shown
in the frmMain.

I tried to access through the following code:
private sub MyProcedur()
....
....
dim frmM as new frmMain()
frmMain.sbar1.panels(0).text = " My string"
End sub

in the second form. Though no error is reported, the text is not shown in
the panels.

how do i do it correctly.

Thanks

Senthil kumar
 
K E Senthil Kumar said:
I tried to access through the following code:
private sub MyProcedur()
...
...
dim frmM as new frmMain()
frmMain.sbar1.panels(0).text = " My string"
End sub

in the second form. Though no error is reported, the text is not
shown in the panels.

You are creating a new instance of your main form instead of reusing the
existing instance:

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainform&lang=en>
 
Hi

in frmMain when you call an other form, in my case a form called Form2 which
has a textbox and a button on it:
<<<<<code>>>>>>
Dim obj As New Form2(Me)
obj.WindowState = FormWindowState.Normal
obj.Show()
<<<<<code>>>>>>

in the called form:
<<<<<code>>>>>>
Private caller As frmMain

'add this inside the #Region " Windows Form Designer generated code "

Public Sub New(ByVal pMainForm As frmMain)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call
caller = pMainForm
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
Try
caller.StatusBar1.Panels(0).Text = TextBox1.Text
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

<<<<<code>>>>>

hth Greetz Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top