public void CollectControlConfigValue(ref Control c) { if (c.Name.Length == 0 || !c.Name.Contains("_")) { return; } string valuePath = c.Name.Replace('_', '.'); switch (c.GetType().ToString()) { case "System.Windows.Forms.TextBox": { this.SetValueByPath(valuePath, ((TextBox)c).Text); break; } case "System.Windows.Forms.CheckBox": { this.SetValueByPath(valuePath, ((CheckBox)c).Checked); break; } case "System.Windows.Forms.ComboBox": { this.SetValueByPath(valuePath, ((ComboBox)c).SelectedItem); break; } case "System.Windows.Forms.RichTextBox": { this.SetValueByPath(valuePath, ((RichTextBox)c).Text); break; } case "System.Windows.Forms.NumericUpDown": { this.SetValueByPath(valuePath, ((NumericUpDown)c).Value); break; } case "System.Windows.Forms.TrackBar": { this.SetValueByPath(valuePath, ((TrackBar)c).Value); break; } case "System.Windows.Forms.VScrollBar": { this.SetValueByPath(valuePath, ((VScrollBar)c).Value); break; } case "System.Windows.Forms.HScrollBar": { this.SetValueByPath(valuePath, ((HScrollBar)c).Value); break; } case "System.Windows.Forms.DataGridView": { Components.HashObject.Com_HashObject hObj = new Components.HashObject.Com_HashObject(); bool useRow = false; foreach (DataGridViewRow drw in ((DataGridView)c).Rows) { useRow = false; foreach (DataGridViewCell testRow in drw.Cells) { if (testRow.Value != null && testRow.Value.ToString() != string.Empty) { useRow = true; break; } } if (useRow) { foreach (DataGridViewCell dcl in drw.Cells) { hObj[drw.Index].Add(dcl.OwningColumn.Name, dcl.Value); } } } this.SetValueByPath(valuePath, hObj.GetHashtable()); break; } default: { break; } } }
public void CollectValueFromSingleControl(ref Control c) { if (c.Name.Length == 0 || !c.Name.Contains("_")) { return; } string valuePath = c.Name.Replace('_', '.'); try { if (!string.IsNullOrEmpty(c.AccessibleDescription)) { this.xP.Commnets.SetValue(c.Name, c.AccessibleDescription); } } catch { } switch (c.GetType().ToString()) { case "System.Windows.Forms.TextBox": { this.SetValueByPath(valuePath, ((TextBox)c).Text); break; } case "System.Windows.Forms.CheckBox": { this.SetValueByPath(valuePath, ((CheckBox)c).Checked); break; } case "System.Windows.Forms.ComboBox": { this.SetValueByPath(valuePath, ((ComboBox)c).SelectedItem); break; } case "System.Windows.Forms.RichTextBox": { this.SetValueByPath(valuePath, ((RichTextBox)c).Text); break; } case "System.Windows.Forms.NumericUpDown": { this.SetValueByPath(valuePath, ((NumericUpDown)c).Value); break; } case "System.Windows.Forms.TrackBar": { this.SetValueByPath(valuePath, ((TrackBar)c).Value); break; } case "System.Windows.Forms.VScrollBar": { this.SetValueByPath(valuePath, ((VScrollBar)c).Value); break; } case "System.Windows.Forms.HScrollBar": { this.SetValueByPath(valuePath, ((HScrollBar)c).Value); break; } case "System.Windows.Forms.DataGridView": { Components.HashObject.Com_HashObject hObj = new Components.HashObject.Com_HashObject(); bool useRow = false; foreach (DataGridViewRow drw in ((DataGridView)c).Rows) { useRow = false; foreach (DataGridViewCell testRow in drw.Cells) { if (testRow.Value != null && testRow.Value.ToString() != string.Empty) { useRow = true; break; } } if (useRow) { foreach (DataGridViewCell dcl in drw.Cells) { hObj[drw.Index.ToString()].Add(dcl.OwningColumn.Name, dcl.Value); } } } this.SetValueByPath(valuePath, hObj.GetHashtable()); break; } /* control access 2 */ case "System.Windows.Forms.CheckedListBox": { //((CheckedListBox)c) Hashtable checkedIndexces = new Hashtable(); int idx = 0; foreach (object checkedItem in ((System.Windows.Forms.CheckedListBox)c).CheckedItems) { checkedIndexces[++idx] = checkedItem; } this.SetValueByPath(valuePath, checkedIndexces); break; } case "System.Windows.Forms.DomainUpDown": { this.SetValueByPath(valuePath, ((DomainUpDown)c).SelectedItem); break; } case "System.Windows.Forms.ListBox": { Hashtable selectedIndexces = new Hashtable(); int idx = 0; foreach (int selectedIndex in ((System.Windows.Forms.ListBox)c).SelectedIndices) { selectedIndexces[++idx] = selectedIndex; } this.SetValueByPath(valuePath, selectedIndexces); break; } case "System.Windows.Forms.DateTimePicker": { this.SetValueByPath(valuePath, ((DateTimePicker)c).Value); break; } default: { break; } } }
public void CollectControlConfigValue(ref Control c) { if (c.Name.Length == 0 || !c.Name.Contains("_")) return; string valuePath = c.Name.Replace('_', '.'); switch (c.GetType().ToString()) { case "System.Windows.Forms.TextBox": { this.SetValueByPath(valuePath, ((TextBox)c).Text); break; } case "System.Windows.Forms.CheckBox": { this.SetValueByPath(valuePath, ((CheckBox)c).Checked); break; } case "System.Windows.Forms.ComboBox": { this.SetValueByPath(valuePath, ((ComboBox)c).SelectedItem); break; } case "System.Windows.Forms.RichTextBox": { this.SetValueByPath(valuePath, ((RichTextBox)c).Text); break; } case "System.Windows.Forms.NumericUpDown": { this.SetValueByPath(valuePath, ((NumericUpDown)c).Value); break; } case "System.Windows.Forms.TrackBar": { this.SetValueByPath(valuePath, ((TrackBar)c).Value); break; } case "System.Windows.Forms.VScrollBar": { this.SetValueByPath(valuePath, ((VScrollBar)c).Value); break; } case "System.Windows.Forms.HScrollBar": { this.SetValueByPath(valuePath, ((HScrollBar)c).Value); break; } case "System.Windows.Forms.DataGridView": { Components.HashObject.Com_HashObject hObj = new Components.HashObject.Com_HashObject(); bool useRow = false; foreach (DataGridViewRow drw in ((DataGridView)c).Rows) { useRow = false; foreach (DataGridViewCell testRow in drw.Cells) if (testRow.Value != null && testRow.Value.ToString() != string.Empty) { useRow = true; break; } if (useRow) foreach (DataGridViewCell dcl in drw.Cells) hObj[drw.Index].Add(dcl.OwningColumn.Name, dcl.Value); } this.SetValueByPath(valuePath, hObj.GetHashtable()); break; } default: { break; } } }