简而言之,我有一堂课:
class MyPanel
{
Panel p_panel; //declaring all the elements I need
CheckBox cb_choice;
RadioButton rb_nagy, rb_kicsi;
TextBox tb_db;
public Panel getPanel() {
create(); //creating all the elements I need, then putting them all in the created Panel.
customize(); //setting the panel's size, and the other control's locations within the panel.
return p_panel; //so if I call this method from an other class, this method will return a panel with all the controls inside.
在另一个类中,我有一个面板列表,所有这些面板都是使用上述方法创建的。布局已经完成,它工作得很整齐,我可以在屏幕上添加任意数量的内容。但现在我想为这些控件添加一些功能。例如,除非启用复选框,否则我希望禁用所有单选按钮。那么如何将检查更改事件添加到面板列表中的所有复选框?