我正在尝试开发一个非常简单的带有单声道和 GTK 锐利的 GUI。我有几个两个组合框,我需要根据第一个中的选定项目更改 secod 中可用的选项:
//Create window container
var mainContainer = new Table (3, 1, false);
//add form
var formContainer = new Table (1, 3, true);
//FIRST COMBOBOX
pdfSelect = new ComboBox(new string[] {"Monthly", "Monthly Offline", "Quarterly" }) { Active = 2 };
pdfSelect.Changed += new EventHandler(OnPdfSelectChanged);
formContainer.Attach (pdfSelect, 1, 2, 0, 1);
//MONTH COMBOBOX
monthSelect = new ComboBox(new string[] { "January","February","March","April","May","June","July","August","September","October","November","December" }){ Active = 0 };
formContainer.Attach(monthSelect, 2, 3, 0, 1);
mainContainer.Attach(formContainer, 0, 1, 0, 1);
win.Add(mainContainer);
我的更改事件如下:
public static void OnPdfSelectChanged(object o, EventArgs args) {
ComboBox combo = o as ComboBox;
if (o == null) return;
if (combo.ActiveText.Equals("Monthly") || combo.ActiveText.Equals("Monthly Offline"))
{
monthSelect = new ComboBox(new string[] { "January","February","March","April","May","June","July",
"August","September","October","November","December" }) { Active = 0 };
}
else
{
monthSelect = new ComboBox(new string[] { "January", "April", "July", "October" }) { Active = 0 };
}
//TODO REFRESH WINDOW
}
该代码有效,但第二个组合框似乎没有更新。我想我需要刷新窗口?
谢谢