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

Re-enable my toolbar button again...

P: n/a
Hi C# wizards,
I would like to ask you the following question:
I'm working on a program with a mainform (a mdiParent called frmMain) and a
childform (called frmNieuwk).
I use the library from CommandBar that gives me the new Luna look from
Micros$oft, so that gives me a toolbar + menubar with several buttons.

Situation is as follows:

When I click on my button newclientButton follwing happens:

private void frmNieuwk_Click(object sender, EventArgs e)
{
frmNieuwk Nieuwe_Klant = new frmNieuwk();
Nieuwe_Klant.MdiParent = this;
Nieuwe_Klant.Show();
this.nklantButton.IsEnabled = false; // <--- this is
the button I spoke about
}

This shows my new client form and disables the button in my toolbar in the
mainform. But now when I close my new client form I also want to enable the
button again. But how? I just cannot access the toolbarbuttons properties
anymore from my clientform. I just wonna enable the button again :-s

I know it's a rather newbie question but I really need help with this. Why
o why did I ever started with VB6 instead of C.... :-(

Any ideas? Help would be appreciated bigtime !
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
in the Closed event of the child form you can do something like this:

(frmMain)(this.MdiParent).nklantButton.IsEnabled = true;
"The_Coolest_Dolphin" <The_Coolest_Dolphin@_Email_hotmail.com> wrote in message
news:Xn*********************************@207.46.24 8.16...
Hi C# wizards,
I would like to ask you the following question:
I'm working on a program with a mainform (a mdiParent called frmMain) and a
childform (called frmNieuwk).
I use the library from CommandBar that gives me the new Luna look from
Micros$oft, so that gives me a toolbar + menubar with several buttons.

Situation is as follows:

When I click on my button newclientButton follwing happens:

private void frmNieuwk_Click(object sender, EventArgs e)
{
frmNieuwk Nieuwe_Klant = new frmNieuwk();
Nieuwe_Klant.MdiParent = this;
Nieuwe_Klant.Show();
this.nklantButton.IsEnabled = false; // <--- this is
the button I spoke about
}

This shows my new client form and disables the button in my toolbar in the
mainform. But now when I close my new client form I also want to enable the
button again. But how? I just cannot access the toolbarbuttons properties
anymore from my clientform. I just wonna enable the button again :-s

I know it's a rather newbie question but I really need help with this. Why
o why did I ever started with VB6 instead of C.... :-(

Any ideas? Help would be appreciated bigtime !

Nov 15 '05 #2

P: n/a
oops, it's my fault, the parenthesis are at the wrong place:

((frmMain)this.MdiParent).nklantButton.IsEnabled = true;

should work
"The_Coolest_Dolphin" <The_Coolest_Dolphin@_Email_hotmail.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
"BenoitM" <Be*********@hotmail.Com> wrote in
news:u8**************@TK2MSFTNGP10.phx.gbl:
in the Closed event of the child form you can do something like this:

(frmMain)(this.MdiParent).nklantButton.IsEnabled = true;

I've tried this but he cannot find my "nklantButton".

In my code I've defined nklantButton as follows:
namespace AFS_Soft_2
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
public System.ComponentModel.IContainer components;

public CommandBarManager commandBarManager = new
CommandBarManager();
public CommandBar menuBar = new CommandBar
(CommandBarStyle.Menu);
public CommandBar toolBar = new CommandBar
(CommandBarStyle.ToolBar);

public CommandBarItem nklantButton;

.......
public void frmMain_Load(object sender, System.EventArgs e)
{

// Definitions for the "Nieuw" menu
this.nklantButton = new CommandBarButton(Images.New, "Nieuwe
&klant", new EventHandler(frmNieuw_Click), Keys.Control | Keys.N);
this.nklantButton.IsEnabled = true;
......

private void frmNieuw_Click(object sender, EventArgs e)
{
frmNieuwk Nieuwe_Klant = new frmNieuwk();
Nieuwe_Klant.MdiParent = this;
Nieuwe_Klant.Show();
this.nklantButton.IsEnabled = false;
}
In my form frmNieuwk I cannot access the nklantButton via above mentioned
method proposed by Benoit.

(frmMain)(this.MdiParent).nklantButton.IsEnabled = true;

Any idea?

Nov 15 '05 #3

P: n/a
"BenoitM" <Be*********@hotmail.Com> wrote in
news:eP**************@TK2MSFTNGP10.phx.gbl:
oops, it's my fault, the parenthesis are at the wrong place:

((frmMain)this.MdiParent).nklantButton.IsEnabled = true;

should work

It does work !! ;-)

What would the world be without guys & girls like you sharing their
knowledge with everybody...

Thank you very much!
Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.