private void _cboTabOfSet_SelectedIndexChanged(object sender, System.EventArgs e) { _dt = _tsk.pResultSet.Tables[_cboTabOfSet.Text]; _dgr.DataSource =_dt; AutoResizeDataGridTableStyle dgs = new AutoResizeDataGridTableStyle(); _dgr.TableStyles.Clear(); dgs.MappingName = _dt.TableName; _dgr.TableStyles.Add(dgs); dgs.OnDataGridResize(dgs, new EventArgs()); _sbpMain.Text = "в таб. "+_dt.Rows.Count+" строк"; }
public ucParamDef(bool aModeDlg) { _params = null; // This call is required by the Windows.Forms Form Designer. InitializeComponent(); #region Create data table and filling it: _dt = new DataTable(); _dt.Columns.Add("Number", typeof(int)); _dt.Columns.Add("Title", typeof(string)); _dt.Columns.Add("Name", typeof(string)); _dt.Columns.Add("Type", typeof(int)); _dt.Columns.Add("Inset", typeof(bool)); _dt.Columns.Add("DefaultValue", typeof(string)); _dt.Columns.Add("CurrentValue", typeof(string)); _dt.Columns.Add("SelectValue", typeof(string)); _dt.Columns["Inset"].DefaultValue = false; _dt.Columns["Type"].DefaultValue = (int)eQueryParamType.String; #endregion _dt.DefaultView.Sort = "Number ASC"; _dgr.DataSource = _dt; #region Create DateGridStyle _dgs = new AutoResizeDataGridTableStyle(); //DataGridTableStyle _dgs = new DataGridTableStyle(); _dgs.AllowSorting = false; DataGridTextBoxColumn dgTextColumn = new DataGridTextBoxColumn(); dgTextColumn.MappingName = "Number"; dgTextColumn.HeaderText = "NN"; dgTextColumn.NullText = string.Empty; _dgs.GridColumnStyles.Add(dgTextColumn); dgTextColumn = new DataGridTextBoxColumn(); dgTextColumn.MappingName = "Title"; dgTextColumn.HeaderText = "Название"; dgTextColumn.NullText = string.Empty; _dgs.GridColumnStyles.Add(dgTextColumn); dgTextColumn = new DataGridTextBoxColumn(); dgTextColumn.MappingName = "Name"; dgTextColumn.HeaderText = "Имя"; dgTextColumn.NullText = string.Empty; _dgs.GridColumnStyles.Add(dgTextColumn); DataGridComboBoxColumnByCode dgComboColumn = new DataGridComboBoxColumnByCode(); dgComboColumn.MappingName = "Type"; dgComboColumn.HeaderText = "Тип"; if (aModeDlg) { foreach (eQueryParamType ep in Enum.GetValues(typeof(eQueryParamType))) dgComboColumn.pCbo.Items.Add(new _ListBoxItem((int)ep, ep.ToString())); } else { dgComboColumn.pCbo.Items.Add(new _ListBoxItem((int)eQueryParamType.Date, eQueryParamType.Date.ToString())); dgComboColumn.pCbo.Items.Add(new _ListBoxItem((int)eQueryParamType.String, eQueryParamType.String.ToString())); dgComboColumn.pCbo.Items.Add(new _ListBoxItem((int)eQueryParamType.Integer, eQueryParamType.Integer.ToString())); //dgComboColumn.pCbo.Items.Add(new _ListBoxItem((int)eQueryParamType.PlaceCode, eQueryParamType.PlaceCode.ToString())); } _dgs.GridColumnStyles.Add(dgComboColumn); DataGridBoolColumn dgsBool = new DataGridBoolColumn(); dgsBool.AllowNull = false; dgsBool.MappingName = "Inset"; dgsBool.HeaderText = "Текст вст."; //dgsBool.NullText = string.Empty; _dgs.GridColumnStyles.Add(dgsBool); if (aModeDlg) { dgTextColumn = new DataGridTextBoxColumn(); dgTextColumn.MappingName = "DefaultValue"; dgTextColumn.HeaderText = "По умолчанию"; dgTextColumn.NullText = string.Empty; _dgs.GridColumnStyles.Add(dgTextColumn); } _dgr.TableStyles.Clear(); _dgr.TableStyles.Add(_dgs); #endregion _txt.AcceptsReturn = true; _txt.AcceptsTab = true; _txt.Font = new Font(_txt.Font.Name, _txt.Font.Size, FontStyle.Bold); Binding bnd = _txt.DataBindings.Add("Text", _dt, aModeDlg ? "SelectValue" : "CurrentValue"); bnd.Format += new ConvertEventHandler(bnd_Format); bnd.Parse += new ConvertEventHandler(bnd_Parse); }