private Control CreateListControl(ObjectData obj, Field field) { ListBoxControl box = new ListBoxControl(this.collection, Data, obj, field); box.DataItemsAdded += new EventHandler <DataItemsEventArgs>(this.box_DataItemsAdded); return(box); }
private void box_DataItemsAdded(object sender, DataItemsEventArgs e) { ListBoxControl list = (ListBoxControl)sender; Field field = (Field)list.Tag; this.AddDataItem(field, e.Items); }
private void SetTextValue(Control c, string value) { Type t = c.GetType(); Field field = (Field)c.Tag; if (t == typeof(KryptonTextBox)) { ((KryptonTextBox)c).Text = value; } else if (t == typeof(KryptonComboBox)) { KryptonComboBox kc = c as KryptonComboBox; if (field.FieldType == FieldType.Select) { int idx = kc.Items.IndexOf(value); if (idx != -1) { kc.SelectedIndex = idx; } } else { bool created = false; ObjectData od = obj.GetReferenceData(field, value, ref created); if (od != null) { int idx = kc.Items.IndexOf(od); if (idx == -1) { kc.Items.Add(od); } kc.SelectedItem = od; if (created) { this.AddDataItem(field, od); } } } } else if (t == typeof(TextBoxNumber)) { TextBoxNumber tbn = c as TextBoxNumber; tbn.Value = decimal.Parse(value); } else if (t == typeof(KryptonDateTimePicker)) { ((KryptonDateTimePicker)c).Value = Convert.ToDateTime(value); } else if (t == typeof(KryptonCheckBox)) { ((KryptonCheckBox)c).Checked = bool.Parse(value); } else if (t == typeof(ListBoxControl)) { ListBoxControl kclb = c as ListBoxControl; if (!string.IsNullOrEmpty(value)) { string[] clb = value.Split(new char[] { ';' }); List <ObjectData> added = new List <ObjectData>(); foreach (string s in clb) { bool created = false; ObjectData od = obj.GetReferenceData(field, s, ref created); if (od != null) { if (!kclb.Exist(od)) { kclb.AddItem(od); if (created) { added.Add(od); } } kclb.SelectData(od); } } this.AddDataItem(field, added); } } }