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

Updating status bar from a class library

P: n/a
Hi Everyone,

I'm very new to C# and I have the following problem - please help.

I have a Windows Forms application called 'FunApp' which has a status
bar. I also have a separate class library called FunTx compiled as a
DLL.

What I want to do is update the status bar from within a FunTx method -
and I used delegates to try this. Here's what I did.

FunApp
--------
delegate void SetStatusBar(void)

in a method of FunApp, I instantiated this

SetStatusBar sb = new SetStatusBar(SetStatusbarText);
where SetStatusBarText is a method that sets the .Text property of the
status bar.

I do the usual stuff like
FunTx ft = new FunTx();
ft.FunProcess(sb,n);

FunTx (separate class library - DLL)
-----
in FunTx I have a method called FunProcess

public void FunProcess(SetStatusBar sb, int y)
{
.....do something....
sb("And now update the status bar");
}
But nothing happens. No change in status bar. What am I doing wrong?
Any help (other ways to do too) is greatly appreciated.

thanks!

Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

Your delegate seem to accept no parameters. How do you expect FunTx to pass
the updated message to be displayed on the status bar?

This line:
sb("And now update the status bar");
should upset the compiler!

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Venu" <mr**********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com... Hi Everyone,

I'm very new to C# and I have the following problem - please help.

I have a Windows Forms application called 'FunApp' which has a status
bar. I also have a separate class library called FunTx compiled as a
DLL.

What I want to do is update the status bar from within a FunTx method -
and I used delegates to try this. Here's what I did.

FunApp
--------
delegate void SetStatusBar(void)

in a method of FunApp, I instantiated this

SetStatusBar sb = new SetStatusBar(SetStatusbarText);
where SetStatusBarText is a method that sets the .Text property of the
status bar.

I do the usual stuff like
FunTx ft = new FunTx();
ft.FunProcess(sb,n);

FunTx (separate class library - DLL)
-----
in FunTx I have a method called FunProcess

public void FunProcess(SetStatusBar sb, int y)
{
....do something....
sb("And now update the status bar");
}
But nothing happens. No change in status bar. What am I doing wrong?
Any help (other ways to do too) is greatly appreciated.

thanks!


Nov 16 '05 #2

P: n/a
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:<OX**************@TK2MSFTNGP14.phx.gbl>...
Hi,

Your delegate seem to accept no parameters. How do you expect FunTx to pass
the updated message to be displayed on the status bar?

This line:
sb("And now update the status bar");
should upset the compiler!

Hi Dmitriy,
Yes it did :) (after I posted the Q) because I was mistakenly not
compiling my class library. Anyway, now I'm lost - I don't know how to
do this. Is there some way I can accomplish this thru my class
library?

-v

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Venu" <mr**********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Hi Everyone,

I'm very new to C# and I have the following problem - please help.

I have a Windows Forms application called 'FunApp' which has a status
bar. I also have a separate class library called FunTx compiled as a
DLL.

What I want to do is update the status bar from within a FunTx method -
and I used delegates to try this. Here's what I did.

FunApp
--------
delegate void SetStatusBar(void)

in a method of FunApp, I instantiated this

SetStatusBar sb = new SetStatusBar(SetStatusbarText);
where SetStatusBarText is a method that sets the .Text property of the
status bar.

I do the usual stuff like
FunTx ft = new FunTx();
ft.FunProcess(sb,n);

FunTx (separate class library - DLL)
-----
in FunTx I have a method called FunProcess

public void FunProcess(SetStatusBar sb, int y)
{
....do something....
sb("And now update the status bar");
}
But nothing happens. No change in status bar. What am I doing wrong?
Any help (other ways to do too) is greatly appreciated.

thanks!

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.