日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

winform空间批量控制

發布時間:2024/4/17 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 winform空间批量控制 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

第一版:

private void RefreshControl(PanelEx panel, bool enabled, bool isClear){for (int i = 0; i < panel.Controls.Count; i++){if (panel.Controls[i] is PanelEx){PanelEx panel1 = panel.Controls[i] as PanelEx;RefreshControl(panel1, enabled, isClear);}else if (panel.Controls[i] is DevComponents.DotNetBar.TabControl){DevComponents.DotNetBar.TabControl tabControl = panel.Controls[i] as DevComponents.DotNetBar.TabControl;RefreshControl(tabControl, enabled, isClear);}else if (panel.Controls[i] is TextBoxX){TextBox textbox = panel.Controls[i] as TextBoxX;textbox.Enabled = enabled;if (isClear)textbox.Clear();}else if (panel.Controls[i] is DateTimeInput){DateTimeInput dtInput = panel.Controls[i] as DateTimeInput;dtInput.Enabled = enabled;if (isClear)dtInput.Value = DateTime.Parse("2999/1/1");}else if (panel.Controls[i] is ButtonX){ButtonX btn = panel.Controls[i] as ButtonX;btn.Enabled = enabled;}else if (panel.Controls[i] is CheckBoxX){CheckBoxX checkBoxX = panel.Controls[i] as CheckBoxX;checkBoxX.Enabled = enabled;if (isClear)checkBoxX.Checked = false;}else if (panel.Controls[i] is BarcodeControl){BarcodeControl barcodeControl = panel.Controls[i] as BarcodeControl;barcodeControl.Enabled = enabled;if (isClear)barcodeControl.Data = "000000000";}else if (panel.Controls[i] is ComboBoxEx){ComboBoxEx comboBoxEx = panel.Controls[i] as ComboBoxEx;comboBoxEx.Enabled = enabled;if (isClear)comboBoxEx.Text = "";}}}private void RefreshControl(DevComponents.DotNetBar.TabControl tabControl, bool enabled, bool isClear){int index = tabControl.SelectedTabIndex;for (int i = 0; i < 5; i++){TabControlPanel panel = tabControl.SelectedPanel;foreach (Control item in panel.Controls){if (item is TextBoxX){TextBox textbox = item as TextBoxX;textbox.Enabled = enabled;if (isClear)textbox.Clear();}else if (item is CheckBoxX){CheckBoxX checkBoxX = item as CheckBoxX;checkBoxX.Enabled = enabled;if (isClear)checkBoxX.Checked = false;}else if (item is ButtonX){ButtonX btn = item as ButtonX;btn.Enabled = enabled;}else if (item is DataGridViewX){DataGridViewX grid = item as DataGridViewX;if (isClear){if (grid.DataSource != null && grid.Rows.Count != 0){DataTable dt = (DataTable)grid.DataSource;dt.Rows.Clear();grid.DataSource = dt;//grid.Rows.Clear(); }}}else if (item is DateTimeInput){DateTimeInput dtInput = item as DateTimeInput;dtInput.Enabled = enabled;if (isClear){dtInput.Value = DateTime.Parse("2999/1/1");}}else if (item is PictureBox){PictureBox pic = item as PictureBox;pic.Enabled = enabled;if (isClear){pic.Image = null;}}else if (item is PanelEx){PanelEx panel1 = item as PanelEx;RefreshControl(panel1, enabled, isClear);}}if (!tabControl.SelectNextTab()){tabControl.SelectedTabIndex = 0;if (tabControl.SelectedTabIndex == index)break;}}tabControl.SelectedTabIndex = index;} View Code

第二版

private void RefreshControl(Control baseControl,bool enabled, bool isClear){foreach (Control Control in baseControl.Controls){if (Control is PanelEx){PanelEx panel = Control as PanelEx;RefreshControl(panel, enabled, isClear);}else if (Control is DevComponents.DotNetBar.TabControl){DevComponents.DotNetBar.TabControl tabControl = Control as DevComponents.DotNetBar.TabControl;RefreshControl(tabControl, enabled, isClear);}else if (Control is TabControlPanel){TabControlPanel tabPanel = Control as TabControlPanel;RefreshControl(tabPanel, enabled, isClear);}else if (Control is TextBoxX){TextBox textbox = Control as TextBoxX;textbox.Enabled = enabled;if (isClear)textbox.Clear();}else if (Control is ButtonX){ButtonX btn = Control as ButtonX;btn.Enabled = enabled;}else if (Control is DateTimeInput){DateTimeInput dtInput = Control as DateTimeInput;dtInput.Enabled = enabled;if (isClear)dtInput.Value = DateTime.Parse("2999/1/1");}else if (Control is CheckBoxX){CheckBoxX checkBoxX = Control as CheckBoxX;checkBoxX.Enabled = enabled;if (isClear)checkBoxX.Checked = false;}else if (Control is BarcodeControl){BarcodeControl barcodeControl = Control as BarcodeControl;barcodeControl.Enabled = enabled;if (isClear)barcodeControl.Data = "000000000";}else if (Control is ComboBoxEx){ComboBoxEx comboBoxEx = Control as ComboBoxEx;comboBoxEx.Enabled = enabled;if (isClear)comboBoxEx.Text = "";}else if (Control is DataGridViewX){DataGridViewX grid = Control as DataGridViewX;if (isClear){if (grid.DataSource != null && grid.Rows.Count != 0){DataTable dt = (DataTable)grid.DataSource;dt.Rows.Clear();grid.DataSource = dt;//grid.Rows.Clear(); }}}else if (Control is PictureBox){PictureBox pic = Control as PictureBox;pic.Enabled = enabled;if (isClear){pic.Image = null;}}else if (Control is GroupPanel){RefreshControl(Control, enabled, isClear);}}} View Code

?

轉載于:https://www.cnblogs.com/liuslayer/p/5772977.html

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的winform空间批量控制的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。