using ComponentFactory.Krypton.Toolkit; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace NXWMS { /// /// 通用工具 /// public static class CommonUtil { /// /// 设定控件组中所有字段值等于Row /// /// /// /// public static void GetGroupControls(TableLayoutPanel container, DataGridView dataView, DataGridViewRow row) { foreach (Control c in container.Controls) { if (c.Tag != null) { if (c.Tag.GetType().Name == "String") { if (dataView.Columns.Contains(c.Tag.ToString())) { switch (c.GetType().Name) { case "KryptonCheckBox": var kryptonCheckBox = (c as KryptonCheckBox); kryptonCheckBox.Checked = (row.Cells[c.Tag.ToString()].Value == null ? "" : row.Cells[c.Tag.ToString()].Value.ToString()) == "1" ? true : false; break; case "CheckBox": var checkbox = (c as KryptonCheckBox); checkbox.Checked = (row.Cells[c.Tag.ToString()].Value == null ? "" : row.Cells[c.Tag.ToString()].Value.ToString()) == "1" ? true : false; break; case "KryptonComboBox": case "ComboBox": case "KryptonTextBox": case "TextBox": default: c.Text = row.Cells[c.Tag.ToString()].Value == null ? "" : row.Cells[c.Tag.ToString()].Value.ToString(); break; } } } } } } /// /// 设定控件组中所有字段值等于空 /// /// /// public static void SetGroupControlsEmpty(TableLayoutPanel container, DataGridView dataView) { foreach (Control c in container.Controls) { if (c.Tag != null) { if (c.Tag.GetType().Name == "String") { if (dataView.Columns.Contains(c.Tag.ToString())) { c.Text = ""; } } } } } } }