E
eramfelt
I have a question on what the "proper" way is to link Controls and
logic? At my current project, which is a C# .NET 2.0 GUI application,
they use events to listen on buttons/lists/menu items. Ie. the code for
linking an action/logic to a button it looks like btn_Clicked(), and so
on (list_DblClicked(), list_KeyUp(), etc.) Is this the preferred way to
link control and logic?
Im having a little issue when it comes to enabling/disabling controls.
Look at this example, and please explain on how you would solve the
problem. I have an application where I want a certain functionality
that is:
* Accessible through a button in the tool bar
* Accessible through a menu item
* Accessible through a short cut
* Accessible through a button in a modeless Form
* Is not always available (Enable = false)
* Logic for the functionality must be in a separate class
So how would you solve this problem?
If I want the functionality to be disabled, do I need to go through all
controls and set Enable = false on them?
If I (later) want the functionality to be called from a ListView, how
can I access it from a list?
If I wanted to do something similar in Java, I would extend the
AbstractAction class and implement my functionality/logic in the
actionPerformed() method. Then I would create one instance of the class
and add it to the button/menu item/tool bar button. All the controls
would use the same Action object. The Action object has a
setEnable(bool) method that disables the action, which means the button
and the menu item will be disabled (grayed out), the short cut key no
longer works, etc. The beauty of this is that the menu/button text
comes from the Action, short cut is defined by Action, everything
(almost) is in one place/class. For more info:
http://shorl.com/gygrobonivuko and http://shorl.com/difagrysajasa
Is there anything similar to the Action (Swing) framework in .NET?
Or do I have to do it manually for every other Button/Menu item?
logic? At my current project, which is a C# .NET 2.0 GUI application,
they use events to listen on buttons/lists/menu items. Ie. the code for
linking an action/logic to a button it looks like btn_Clicked(), and so
on (list_DblClicked(), list_KeyUp(), etc.) Is this the preferred way to
link control and logic?
Im having a little issue when it comes to enabling/disabling controls.
Look at this example, and please explain on how you would solve the
problem. I have an application where I want a certain functionality
that is:
* Accessible through a button in the tool bar
* Accessible through a menu item
* Accessible through a short cut
* Accessible through a button in a modeless Form
* Is not always available (Enable = false)
* Logic for the functionality must be in a separate class
So how would you solve this problem?
If I want the functionality to be disabled, do I need to go through all
controls and set Enable = false on them?
If I (later) want the functionality to be called from a ListView, how
can I access it from a list?
If I wanted to do something similar in Java, I would extend the
AbstractAction class and implement my functionality/logic in the
actionPerformed() method. Then I would create one instance of the class
and add it to the button/menu item/tool bar button. All the controls
would use the same Action object. The Action object has a
setEnable(bool) method that disables the action, which means the button
and the menu item will be disabled (grayed out), the short cut key no
longer works, etc. The beauty of this is that the menu/button text
comes from the Action, short cut is defined by Action, everything
(almost) is in one place/class. For more info:
http://shorl.com/gygrobonivuko and http://shorl.com/difagrysajasa
Is there anything similar to the Action (Swing) framework in .NET?
Or do I have to do it manually for every other Button/Menu item?