/// <summary> /// Binds a DataSource to this GuiGrid. Binding supports SimpleTables, DataTables, DataViews, and other IEnumerable classes. /// </summary> /// <param name="dataSource">The data source object to bind.</param> public void BindData(object dataSource) { #if !HTML_HELP if (dataSource is SimpleTable) { this.DataSource = dataSource as SimpleTable; } else { this.DataSource = SimpleTableTools.ConvertToSimpleTable(dataSource); } #endif }
public void UpdateData() { Control w32ctrl; foreach (GuiControl control in guiControls.Values) { w32ctrl = win32Controls[control.ID] as Control; if (control is GuiLabel) { GuiLabel guiLabel = control as GuiLabel; Label l = w32ctrl as Label; guiLabel.Text = l.Text; } else if (control is GuiButton) { GuiButton guiButton = control as GuiButton; Button b = w32ctrl as Button; guiButton.Text = b.Text; } else if (control is GuiCheckBox) { GuiCheckBox guiCheckBox = control as GuiCheckBox; CheckBox cb = w32ctrl as CheckBox; guiCheckBox.Text = cb.Text; guiCheckBox.Checked = cb.Checked; } else if (control is GuiFilePicker) { GuiFilePicker guiPicker = control as GuiFilePicker; Button b = w32ctrl as Button; guiPicker.Text = b.Text; b.Tag = win32Controls[guiPicker.TargetControl]; } else if (control is GuiTextBox) { GuiTextBox guiTextBox = control as GuiTextBox; TextBox tb = w32ctrl as TextBox; guiTextBox.Text = tb.Text; } else if (control is GuiComboBox) { GuiComboBox guiComboBox = control as GuiComboBox; ComboBox cb = w32ctrl as ComboBox; if (cb.SelectedItem is ListControlItem) { guiComboBox.SelectedValue = ((ListControlItem)cb.SelectedItem).Value; } } else if (control is GuiListBox) { GuiListBox guiListBox = control as GuiListBox; ListBox lb = w32ctrl as ListBox; guiListBox.Clear(); foreach (ListControlItem item in lb.Items) { guiListBox[item.Value] = item.Text; } foreach (ListControlItem item in lb.SelectedItems) { guiListBox.SelectedItems.Add(item.Value); } } else if (control is GuiGrid) { GuiGrid guiGrid = control as GuiGrid; DataGrid dg = w32ctrl as DataGrid; guiGrid.DataSource = SimpleTableTools.ConvertToSimpleTable(dg.DataSource as DataTable); } else if (control is GuiCheckBoxList) { GuiCheckBoxList guiCheckBoxList = control as GuiCheckBoxList; CheckedListBox lb = w32ctrl as CheckedListBox; guiCheckBoxList.Clear(); foreach (ListControlItem item in lb.Items) { guiCheckBoxList[item.Value] = item.Text; } foreach (ListControlItem item in lb.CheckedItems) { guiCheckBoxList.SelectedItems.Add(item.Value); } } } }