G
Guest
C# .Net
My application is a one window one world one love, type of affair. There
are the occasional pop up screens, but in the main it is one window, and all
screens are displayed within this one window. Down the left hand side of my
MainWindow is a menu structure, and when you select an item, it creates an
instance of the relevant UserControl and renders it in the right hand side of
MainMenu.
Until now, each "page" or user control has its own set of buttons on it for
add,update,delete,cancel etc. Which is fine, because when the user presses a
button then the code for handling each one of these actions is within that
UserControl's code.
However.... I want to move these individual toolbars out of the individual
controls, and have one toolbar, in the MainWindow at the top. I have placed
this toolbar into my Mainwindow, and have some methods for adding and
removing buttons to it, depending on which screen I am in. But how do I tell
the control on that screen, which button has been pressed? I could I guess
use reflection to run a method in the actual control, from the ToolBar
clicked in the MainWindow, but this seems a bit bodgey.
I am new to C# and OOP, and I'm sure there is a better way, but I dont know
it. Would this be a good use for Delegates and/or Intefaces??
My application is a one window one world one love, type of affair. There
are the occasional pop up screens, but in the main it is one window, and all
screens are displayed within this one window. Down the left hand side of my
MainWindow is a menu structure, and when you select an item, it creates an
instance of the relevant UserControl and renders it in the right hand side of
MainMenu.
Until now, each "page" or user control has its own set of buttons on it for
add,update,delete,cancel etc. Which is fine, because when the user presses a
button then the code for handling each one of these actions is within that
UserControl's code.
However.... I want to move these individual toolbars out of the individual
controls, and have one toolbar, in the MainWindow at the top. I have placed
this toolbar into my Mainwindow, and have some methods for adding and
removing buttons to it, depending on which screen I am in. But how do I tell
the control on that screen, which button has been pressed? I could I guess
use reflection to run a method in the actual control, from the ToolBar
clicked in the MainWindow, but this seems a bit bodgey.
I am new to C# and OOP, and I'm sure there is a better way, but I dont know
it. Would this be a good use for Delegates and/or Intefaces??