By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,600 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,600 IT Pros & Developers. It's quick & easy.

status bar

P: n/a
Ada
i have a little bit of issue getting the status bar to work properly.
this is what happens now.

when the program loaded, the status is "READY..."
the code is inside the FORM LOAD.

i also added the same code in another CLICK METHOD.
everytime i click, the status got updated but the old "READY..." got moved up one line above.
so, if i click 10 times, i got a stack of 10 rows of status bar.

the question is.......
how do i destroy the old status bar and update the new info and leaving it at the same position?
thanks in advance,
Ada


Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi Ada,

Typically, the StatusBar.Text or the StatusBarPanel.Text property (if using
panels
in the status bar) should take care of updating the status bar text.
Can you post a snippet of code in your Click handler that
updates the status bar text ?.
That will help us track down the cause of the issue

Regards,
Aravind C
"Ada" <an*******@discussions.microsoft.com> wrote in message
news:CC**********************************@microsof t.com...
i have a little bit of issue getting the status bar to work properly.
this is what happens now.

when the program loaded, the status is "READY..."
the code is inside the FORM LOAD.

i also added the same code in another CLICK METHOD.
everytime i click, the status got updated but the old "READY..." got moved up one line above. so, if i click 10 times, i got a stack of 10 rows of status bar.

the question is.......
how do i destroy the old status bar and update the new info and leaving it at the same position?

thanks in advance,
Ada

Nov 15 '05 #2

P: n/a
Ada
hi AC

below is the snippet
note, this is the exact same code in MSDN

// // Create a StatusBar control
// StatusBar statusBar1 = new StatusBar()
/
// StatusBarPanel panel1 = new StatusBarPanel()

// panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken
// // Initialize the text of the panel
// panel1.Text = "Ready..."
// // Set the AutoSize property to use all remaining space on the StatusBar
// panel1.AutoSize = StatusBarPanelAutoSize.Spring
//
// // Display panels in the StatusBar control
// statusBar1.ShowPanels = true
//
// statusBar1.Panels.Add(panel1)
//
/
// // Add the StatusBar to the form
// this.Controls.Add(statusBar1)

----- Aravind C wrote: ----

Hi Ada

Typically, the StatusBar.Text or the StatusBarPanel.Text property (if usin
panel
in the status bar) should take care of updating the status bar text
Can you post a snippet of code in your Click handler tha
updates the status bar text ?
That will help us track down the cause of the issu

Regards
Aravind
"Ada" <an*******@discussions.microsoft.com> wrote in messag
news:CC**********************************@microsof t.com..
i have a little bit of issue getting the status bar to work properly
this is what happens now
when the program loaded, the status is "READY... the code is inside the FORM LOAD
i also added the same code in another CLICK METHOD

everytime i click, the status got updated but the old "READY..." got move

up one line above so, if i click 10 times, i got a stack of 10 rows of status bar
the question is......

how do i destroy the old status bar and update the new info and leaving i

at the same position
thanks in advance Ad

Nov 15 '05 #3

P: n/a
Hi Ada,

From what I undestand, in your Click handler, you call the
snippet of code that you posted. Correct ?.

Actually, you must call the code that creates and adds the
status bar to the form's control collection only once -
prefeably in the designer generated InitializeComponent()
called in the Form's Constructor or in Form's Load event handler.
Otherwise we would end up creating and adding multiple instances of the
status bar to the windows form - which explains the behavior
you're seeing with the status bars being stacked one on top of another.

For updating the status bar's text, it may be enough to call,
panel1.Text = "....some text ...."; in your Click handler.

Regards,
Aravind C
"Ada" <an*******@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
hi AC,

below is the snippet.
note, this is the exact same code in MSDN.
// // Create a StatusBar control.
// StatusBar statusBar1 = new StatusBar();
//
// StatusBarPanel panel1 = new StatusBarPanel();

// panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken;
// // Initialize the text of the panel.
// panel1.Text = "Ready...";
// // Set the AutoSize property to use all remaining space on the StatusBar. // panel1.AutoSize = StatusBarPanelAutoSize.Spring;
//
// // Display panels in the StatusBar control.
// statusBar1.ShowPanels = true;
//
// statusBar1.Panels.Add(panel1);
//
//
// // Add the StatusBar to the form.
// this.Controls.Add(statusBar1);


----- Aravind C wrote: -----

Hi Ada,

Typically, the StatusBar.Text or the StatusBarPanel.Text property (if using panels
in the status bar) should take care of updating the status bar text.
Can you post a snippet of code in your Click handler that
updates the status bar text ?.
That will help us track down the cause of the issue

Regards,
Aravind C
"Ada" <an*******@discussions.microsoft.com> wrote in message
news:CC**********************************@microsof t.com...
> i have a little bit of issue getting the status bar to work properly.
> this is what happens now.
>> when the program loaded, the status is "READY..." > the code is inside the FORM LOAD.
>> i also added the same code in another CLICK METHOD.

> everytime i click, the status got updated but the old "READY..."

got moved up one line above.
> so, if i click 10 times, i got a stack of 10 rows of status bar.
>> the question is....... > how do i destroy the old status bar and update the new info and

leaving it at the same position? >>> thanks in advance,

> Ada
>>>>

Nov 15 '05 #4

P: n/a
Ada
hi AC

that's what i did previously before i posted the message on this board
i was thinking because the code, although it's the same, appear twice in different method, C# compiler would do all the clean up automatically

i tried your suggestion below
no go
code doesn't even compile
err msg
C:\Form1.cs(694): The type or namespace name 'panel1' could not be found (are you missing a using directive or an assembly reference?

i think what happened here is that although the object got instantiated on the LOAD FORM method but it got destroyed when it exited LOAD FORM
when i click on another method which contained the same code, it looks for the INSTANCE
in this case, of course, i think it's out of scope
this is the reason why i added all enchilada again
obvioulsy, something didn't go as plan

i was thinking may be there's a DISPOSE() method somewhere i can call before create the new instance in the new method
may be that can take care of the problem

anyhow, i'm all open for any advice. :-

--Ad


----- Aravind C wrote: ----

Hi Ada

From what I undestand, in your Click handler, you call th
snippet of code that you posted. Correct ?

Actually, you must call the code that creates and adds th
status bar to the form's control collection only once
prefeably in the designer generated InitializeComponent(
called in the Form's Constructor or in Form's Load event handler
Otherwise we would end up creating and adding multiple instances of th
status bar to the windows form - which explains the behavio
you're seeing with the status bars being stacked one on top of another

For updating the status bar's text, it may be enough to call
panel1.Text = "....some text ...."; in your Click handler

Regards
Aravind
"Ada" <an*******@discussions.microsoft.com> wrote in messag
news:BC**********************************@microsof t.com..
hi AC
below is the snippet note, this is the exact same code in MSDN
// // Create a StatusBar control // StatusBar statusBar1 = new StatusBar()
/
// StatusBarPanel panel1 = new StatusBarPanel()
// panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken

// // Initialize the text of the panel
// panel1.Text = "Ready..."
// // Set the AutoSize property to use all remaining space on th

StatusBar // panel1.AutoSize = StatusBarPanelAutoSize.Spring
/
// // Display panels in the StatusBar control
// statusBar1.ShowPanels = true
/
// statusBar1.Panels.Add(panel1)
/
/
// // Add the StatusBar to the form
// this.Controls.Add(statusBar1)> ----- Aravind C wrote: ---- Hi Ada
Typically, the StatusBar.Text or the StatusBarPanel.Text property (i usin panel
in the status bar) should take care of updating the status bar text
Can you post a snippet of code in your Click handler tha
updates the status bar text ?
That will help us track down the cause of the issu
Regards Aravind "Ada" <an*******@discussions.microsoft.com> wrote in messag news:CC**********************************@microsof t.com..
i have a little bit of issue getting the status bar to wor properly this is what happens now
when the program loaded, the status is "READY...

the code is inside the FORM LOAD
i also added the same code in another CLICK METHOD

everytime i click, the status got updated but the old "READY...

got move up one line above
so, if i click 10 times, i got a stack of 10 rows of status bar
the question is...... how do i destroy the old status bar and update the new info an

leaving i at the same position thanks in advance

Ada
>

Nov 15 '05 #5

P: n/a
Hi Ada,

Actually, you must make the statusbar and its panels as _instance fields_
of the Form so that the form can access them from any method.
The windows form designer should automatically do this for you once you
drag and drop a status bar from the toolbox into the form.

public class MyForm : System.Windows.Forms.Form
{
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;

private void InitializeComponent()
{

this.statusBar1.Location = new System.Drawing.Point(0, 328);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[]
{
this.statusBarPanel1});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(672, 22);
this.statusBar1.TabIndex = 2;
this.statusBar1.Text = "statusBar1";
this.statusBarPanel1.BorderStyle =
System.Windows.Forms.StatusBarPanelBorderStyle.Rai sed;
this.statusBarPanel1.Text = "Ready....";
this.statusBarPanel1.ToolTipText = "Test";

// ....

}

// Update the status panel's text
private void button1_Click(object sender, System.EventArgs e)
{
this.statusBarPanel1.Text = "Button clicked...";
}
}
Regards,
Aravind C

"Ada" <an*******@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
hi AC,

that's what i did previously before i posted the message on this board.
i was thinking because the code, although it's the same, appear twice in different method, C# compiler would do all the clean up automatically.
i tried your suggestion below.
no go.
code doesn't even compile.
err msg:
C:\Form1.cs(694): The type or namespace name 'panel1' could not be found (are you missing a using directive or an assembly reference?)

i think what happened here is that although the object got instantiated on the LOAD FORM method but it got destroyed when it exited LOAD FORM. when i click on another method which contained the same code, it looks for the INSTANCE. in this case, of course, i think it's out of scope.
this is the reason why i added all enchilada again.
obvioulsy, something didn't go as plan.

i was thinking may be there's a DISPOSE() method somewhere i can call before create the new instance in the new method. may be that can take care of the problem.

anyhow, i'm all open for any advice. :-)
--Ada


----- Aravind C wrote: -----

Hi Ada,

From what I undestand, in your Click handler, you call the
snippet of code that you posted. Correct ?.

Actually, you must call the code that creates and adds the
status bar to the form's control collection only once -
prefeably in the designer generated InitializeComponent()
called in the Form's Constructor or in Form's Load event handler.
Otherwise we would end up creating and adding multiple instances of the status bar to the windows form - which explains the behavior
you're seeing with the status bars being stacked one on top of another.
For updating the status bar's text, it may be enough to call,
panel1.Text = "....some text ...."; in your Click handler.

Regards,
Aravind C
"Ada" <an*******@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
> hi AC,
>> below is the snippet. > note, this is the exact same code in MSDN.
>>> // // Create a StatusBar control.

> // StatusBar statusBar1 = new StatusBar();
> //
> // StatusBarPanel panel1 = new StatusBarPanel();
>> // panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken;

> // // Initialize the text of the panel.
> // panel1.Text = "Ready...";
> // // Set the AutoSize property to use all remaining space on the

StatusBar.
> // panel1.AutoSize = StatusBarPanelAutoSize.Spring;
> //
> // // Display panels in the StatusBar control.
> // statusBar1.ShowPanels = true;
> //
> // statusBar1.Panels.Add(panel1);
> //
> //
> // // Add the StatusBar to the form.
> // this.Controls.Add(statusBar1);
>>>>> ----- Aravind C wrote: -----
>> Hi Ada,
>> Typically, the StatusBar.Text or the StatusBarPanel.Text
property (if using
> panels
> in the status bar) should take care of updating the status bar text. > Can you post a snippet of code in your Click handler that
> updates the status bar text ?.
> That will help us track down the cause of the issue
>> Regards,

> Aravind C
>>> "Ada" <an*******@discussions.microsoft.com> wrote in message

> news:CC**********************************@microsof t.com...
>> i have a little bit of issue getting the status bar to work

properly. >> this is what happens now.
>>> when the program loaded, the status is "READY..."
>> the code is inside the FORM LOAD.
>>> i also added the same code in another CLICK METHOD.
>> everytime i click, the status got updated but the old "READY..."

got moved
> up one line above.
>> so, if i click 10 times, i got a stack of 10 rows of status bar.
>>> the question is.......
>> how do i destroy the old status bar and update the new info and

leaving it
> at the same position?
>>>> thanks in advance,
>> Ada
>>>>>

Nov 15 '05 #6

P: n/a
Ada
hi AC

i think your suggestion might work
this is what i have in mind also

if i make it GLOBAL (as you suggested), then i don't have to recreate the object everytime

i will give this code a try after i woke up
it is about 4 a.m. my time zone now
betta catch some zzzzzzzzzzz

thanks for all the help
Ad


----- Aravind C wrote: ----

Hi Ada

Actually, you must make the statusbar and its panels as _instance fields
of the Form so that the form can access them from any method
The windows form designer should automatically do this for you once yo
drag and drop a status bar from the toolbox into the form

public class MyForm : System.Windows.Forms.For

private System.Windows.Forms.StatusBar statusBar1
private System.Windows.Forms.StatusBarPanel statusBarPanel1

private void InitializeComponent(
this.statusBar1.Location = new System.Drawing.Point(0, 328)
this.statusBar1.Name = "statusBar1"
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[

this.statusBarPanel1})
this.statusBar1.ShowPanels = true
this.statusBar1.Size = new System.Drawing.Size(672, 22)
this.statusBar1.TabIndex = 2
this.statusBar1.Text = "statusBar1"
this.statusBarPanel1.BorderStyle
System.Windows.Forms.StatusBarPanelBorderStyle.Rai sed
this.statusBarPanel1.Text = "Ready...."
this.statusBarPanel1.ToolTipText = "Test"

// ...

// Update the status panel's tex
private void button1_Click(object sender, System.EventArgs e

this.statusBarPanel1.Text = "Button clicked..."


Regards
Aravind

"Ada" <an*******@discussions.microsoft.com> wrote in messag
news:A3**********************************@microsof t.com..
hi AC
that's what i did previously before i posted the message on this board i was thinking because the code, although it's the same, appear twice i

different method, C# compiler would do all the clean up automatically
i tried your suggestion below

no go
code doesn't even compile
err msg
C:\Form1.cs(694): The type or namespace name 'panel1' could not be foun

(are you missing a using directive or an assembly reference?
i think what happened here is that although the object got instantiated o
the LOAD FORM method but it got destroyed when it exited LOAD FORM when i click on another method which contained the same code, it looks fo the INSTANCE in this case, of course, i think it's out of scope
this is the reason why i added all enchilada again
obvioulsy, something didn't go as plan
i was thinking may be there's a DISPOSE() method somewhere i can cal before create the new instance in the new method
may be that can take care of the problem
anyhow, i'm all open for any advice. :-
--Ad
>>> ----- Aravind C wrote: ---- Hi Ada
From what I undestand, in your Click handler, you call th

snippet of code that you posted. Correct ?
Actually, you must call the code that creates and adds th

status bar to the form's control collection only once
prefeably in the designer generated InitializeComponent(
called in the Form's Constructor or in Form's Load event handler
Otherwise we would end up creating and adding multiple instances o

th status bar to the windows form - which explains the behavio
you're seeing with the status bars being stacked one on top o another For updating the status bar's text, it may be enough to call

panel1.Text = "....some text ...."; in your Click handler
Regards

Aravind "Ada" <an*******@discussions.microsoft.com> wrote in message news:BC**********************************@microsof t.com...
hi AC,
below is the snippet.

note, this is the exact same code in MSDN.
// // Create a StatusBar control.

// StatusBar statusBar1 = new StatusBar();
//
// StatusBarPanel panel1 = new StatusBarPanel();
// panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken;

// // Initialize the text of the panel.
// panel1.Text = "Ready...";
// // Set the AutoSize property to use all remaining space on the

StatusBar.
// panel1.AutoSize = StatusBarPanelAutoSize.Spring;
//
// // Display panels in the StatusBar control.
// statusBar1.ShowPanels = true;
//
// statusBar1.Panels.Add(panel1);
//
//
// // Add the StatusBar to the form.
// this.Controls.Add(statusBar1);
>> ----- Aravind C wrote: -----
Hi Ada,
Typically, the StatusBar.Text or the StatusBarPanel.Text
property (if using
panels
in the status bar) should take care of updating the status bar

text. Can you post a snippet of code in your Click handler that
updates the status bar text ?.
That will help us track down the cause of the issue
Regards,

Aravind C
"Ada" <an*******@discussions.microsoft.com> wrote in message

news:CC**********************************@microsof t.com...
i have a little bit of issue getting the status bar to work

properly. this is what happens now.
when the program loaded, the status is "READY..."
the code is inside the FORM LOAD.
i also added the same code in another CLICK METHOD.
everytime i click, the status got updated but the old "READY..."

got moved
up one line above.
so, if i click 10 times, i got a stack of 10 rows of status bar.
the question is.......
how do i destroy the old status bar and update the new info and

leaving it
at the same position?
> thanks in advance,
Ada
>>

Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.