private void cbxField_SelectedIndexChanged(object sender, System.EventArgs e) { lstOP.Items.Clear(); int n = cbxField.SelectedIndex; if (n >= 0) { int i; EPField fld = cbxField.Items[n] as EPField; if (EPField.IsString(fld.OleDbType) || EPField.IsBinary(fld.OleDbType)) { for (i = 0; i < opList.Count; i++) { lstOP.Items.Add(opList[i]); } } else if (EPField.IsBoolean(fld.OleDbType)) { lstOP.Items.Add(opList[0]); } else { for (i = 0; i < opList.Count; i++) { if (!opList[i].bStringOnly) { lstOP.Items.Add(opList[i]); } } } if (lstOP.Items.Count > 0) { lstOP.SelectedIndex = 0; } } }
public void LoadData(DataGridViewColumnCollection cols) { _cols = cols; _tbl = new DataTable(); _tbl.Columns.Add("ColumnName", typeof(string)); _tbl.Columns[0].ReadOnly = true; _tbl.Columns.Add("HeaderText", typeof(string)); _tbl.Columns.Add("DataType", typeof(string)); for (int i = 0; i < cols.Count; i++) { OleDbType t = OleDbType.VarWChar; if (cols[i].ValueType != null) { t = EPField.ToOleDBType(cols[i].ValueType); } string tx; if (t == OleDbType.DBTime) { tx = "Time"; } else if (EPField.IsDatetime(t)) { tx = "DateTime"; } else if (EPField.IsInteger(t)) { tx = "Integer"; } else if (EPField.IsNumber(t)) { tx = "Decimal"; } else if (EPField.IsBoolean(t)) { tx = "Boolean"; } else { tx = "Text"; } string s = cols[i].DataPropertyName; if (string.IsNullOrEmpty(s)) { s = cols[i].HeaderText; if (string.IsNullOrEmpty(s)) { s = cols[i].Name; } } string sh = cols[i].HeaderText; if (string.IsNullOrEmpty(sh)) { sh = cols[i].DataPropertyName; if (string.IsNullOrEmpty(sh)) { sh = cols[i].Name; } } _tbl.Rows.Add(s, sh, tx); } dataGridView1.AllowUserToAddRows = false; dataGridView1.AllowUserToDeleteRows = false; dataGridView1.AllowUserToOrderColumns = false; dataGridView1.AllowUserToResizeRows = false; dataGridView1.Columns.Clear(); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = _tbl; dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; }