public void UnSelectAllDefinitionFiles() { int tempCount = 0; DvtkApplicationLayer.Session theSession = GetSessionTreeViewManager().GetSession(); DataGridBoolColumn dataBoolColumn = new DataGridBoolColumn(); foreach (DefinitionFile theDefinitionFile in _DefinitionFilesInfoForDataGrid) { string theFullFileName = System.IO.Path.Combine(theDefinitionFile.DefinitionRoot, theDefinitionFile.Filename); theSession.Implementation.DefinitionManagement.UnLoadDefinitionFile(theFullFileName); //_DataGridSopClasses[tempCount,0] = dataBoolColumn.FalseValue; // Get the column style for the "loaded" column. DataGridColumnStyle theColStyle = _DataGridSopClasses.TableStyles[0].GridColumnStyles[0]; // Change the "loaded" stated in _DefinitionFilesInfoForDataGrid and the data grid itself. _DataGridSopClasses.BeginEdit(theColStyle, tempCount); theDefinitionFile.Loaded = false; _DataGridSopClasses.EndEdit(theColStyle, tempCount, false); tempCount++; } _DataGridSopClasses.SetDataBinding(_DefinitionFilesInfoForDataGrid, ""); // Notify the rest of the world. SessionChange theSessionChange = new SessionChange(theSession, SessionChange.SessionChangeSubTypEnum.SOP_CLASSES_LOADED_STATE); Notify(theSessionChange); }
/// <summary> /// /// </summary> /// <param name="tableMappingName"></param> /// <param name="dbColName"></param> /// <param name="dgShowName"></param> /// <param name="boolColumnIndex"></param> /// <returns></returns> static public DataGridTableStyle CreateDataGridTableStyle(string tableMappingName, string[] dbColName, string[] dgShowName, int[] boolColumnIndex) { ArgumentChecker.CheckNotNull(dbColName); ArgumentChecker.CheckNotNull(dgShowName); if (dbColName.Length != dgShowName.Length) { throw new ArgumentException("dbColName.Length != dgShowName.Length"); } DataGridTableStyle dgts = new DataGridTableStyle(); dgts.MappingName = tableMappingName; DataGridColumnStyle dgcs = null; for (int i = 0; i < dbColName.Length; i++) { if (InArray(boolColumnIndex, i)) { dgcs = new DataGridBoolColumn(); } else { dgcs = new DataGridTextBoxColumn(); } dgcs.MappingName = dbColName[i]; dgcs.HeaderText = dgShowName[i]; dgts.GridColumnStyles.Add(dgcs); } return(dgts); }
//</snippet3> //<snippet4> private void AddDataGridTableStyle() { // Create a new DataGridTableStyle and set MappingName. DataGridTableStyle myGridStyle = new DataGridTableStyle(); myGridStyle.MappingName = "Customers"; // Create two DataGridColumnStyle objects. DataGridColumnStyle colStyle1 = new DataGridTextBoxColumn(); colStyle1.MappingName = "firstName"; DataGridColumnStyle colStyle2 = new DataGridBoolColumn(); colStyle2.MappingName = "Current"; // Add column styles to table style. myGridStyle.GridColumnStyles.Add(colStyle1); myGridStyle.GridColumnStyles.Add(colStyle2); // Add the grid style to the GridStylesCollection. myDataGrid.TableStyles.Add(myGridStyle); }
// <Snippet1> private void AddCustomDataTableStyle() { /* Create a new DataGridTableStyle and set * its MappingName to the TableName of a DataTable. */ DataGridTableStyle ts1 = new DataGridTableStyle(); ts1.MappingName = "Customers"; /* Add a GridColumnStyle and set its MappingName * to the name of a DataColumn in the DataTable. * Set the HeaderText and Width properties. */ DataGridColumnStyle boolCol = new DataGridBoolColumn(); boolCol.MappingName = "Current"; boolCol.HeaderText = "IsCurrent Customer"; boolCol.Width = 150; ts1.GridColumnStyles.Add(boolCol); // Add a second column style. DataGridColumnStyle TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "custName"; TextCol.HeaderText = "Customer Name"; TextCol.Width = 250; ts1.GridColumnStyles.Add(TextCol); // Create the second table style with columns. DataGridTableStyle ts2 = new DataGridTableStyle(); ts2.MappingName = "Orders"; // Change the colors. ts2.ForeColor = Color.Yellow; ts2.AlternatingBackColor = Color.Blue; ts2.BackColor = Color.Blue; // Create new DataGridColumnStyle objects. DataGridColumnStyle cOrderDate = new DataGridTextBoxColumn(); cOrderDate.MappingName = "OrderDate"; cOrderDate.HeaderText = "Order Date"; cOrderDate.Width = 100; ts2.GridColumnStyles.Add(cOrderDate); PropertyDescriptorCollection pcol = this.BindingContext [myDataSet, "Customers.custToOrders"].GetItemProperties(); DataGridColumnStyle csOrderAmount = new DataGridTextBoxColumn(pcol["OrderAmount"], "c", true); csOrderAmount.MappingName = "OrderAmount"; csOrderAmount.HeaderText = "Total"; csOrderAmount.Width = 100; ts2.GridColumnStyles.Add(csOrderAmount); // Add the DataGridTableStyle objects to the collection. myDataGrid.TableStyles.Add(ts1); myDataGrid.TableStyles.Add(ts2); }
/// <summary> /// 初始化mydataGrid网格 /// </summary> /// <param name="mydataGrid"></param> /// <param name="HeaderText"></param> /// <param name="ColumnMappingName"></param> /// <param name="BoolColumn"></param> /// <param name="GrdWidth"></param> /// <param name="AllowSorting"></param> public static void csMydataGrid(myDataGrid.myDataGrid mydataGrid, string[] HeaderText, string[] ColumnMappingName, bool[] BoolColumn, int[] GrdWidth, bool AllowSorting) { mydataGrid.TableStyles[0].MappingName = "dataGridTableStyle1"; mydataGrid.TableStyles[0].MappingName = "Tb"; mydataGrid.TableStyles[0].AllowSorting = AllowSorting; //不允许排序 for (int i = 0; i <= ColumnMappingName.Length - 1; i++) { if (BoolColumn[i] == false) { System.Windows.Forms.DataGridTextBoxColumn aColumnTextColumn; aColumnTextColumn = new DataGridTextBoxColumn(); mydataGrid.TableStyles[0].GridColumnStyles.Add(aColumnTextColumn); } else { System.Windows.Forms.DataGridBoolColumn aColumnBoolColumn; aColumnBoolColumn = new DataGridBoolColumn(); aColumnBoolColumn.AllowNull = false; aColumnBoolColumn.NullValue = ((short)(0)); aColumnBoolColumn.FalseValue = ((short)(0)); aColumnBoolColumn.TrueValue = ((short)(1)); mydataGrid.TableStyles[0].GridColumnStyles.Add(aColumnBoolColumn); } mydataGrid.TableStyles[0].GridColumnStyles[i].MappingName = ColumnMappingName[i].ToString(); mydataGrid.TableStyles[0].GridColumnStyles[i].HeaderText = HeaderText[i].ToString().Trim(); mydataGrid.TableStyles[0].GridColumnStyles[i].Width = GrdWidth[i]; mydataGrid.TableStyles[0].GridColumnStyles[i].NullText = ""; } }
// <Snippet1> private void AddDataGridBoolColumnStyle() { DataGridBoolColumn myColumn = new DataGridBoolColumn(); myColumn.MappingName = "Current"; myColumn.Width = 200; dataGrid1.TableStyles["Customers"].GridColumnStyles.Add(myColumn); }
// <Snippet1> // <Snippet2> // <Snippet3> private void RegisterEventHandlers(DataGridBoolColumn myDataGridBoolColumn) { myDataGridBoolColumn.AllowNullChanged += new System.EventHandler(myDataGridBoolColumn_AllowNullChanged); myDataGridBoolColumn.TrueValueChanged += new System.EventHandler(myDataGridBoolColumn_TrueValueChanged); myDataGridBoolColumn.FalseValueChanged += new System.EventHandler(myDataGridBoolColumn_FalseValueChanged); }
private void AddCustomDataTableStyle() { // Create a 'DataGridTableStyle'. DataGridTableStyle myTableStyle1 = new DataGridTableStyle(); // Map the table style. myTableStyle1.MappingName = "Customers"; myTableStyle1.AlternatingBackColor = Color.LightGray; // Add a Name column style. DataGridColumnStyle myTextCol = new DataGridTextBoxColumn(); myTextCol.MappingName = "CustName"; myTextCol.HeaderText = "Customer Name"; myTextCol.Width = 100; myTableStyle1.GridColumnStyles.Add(myTextCol); // Add a Current column style. DataGridColumnStyle myBoolCol = new DataGridBoolColumn(); myBoolCol.MappingName = "Current"; myBoolCol.HeaderText = "IsCurrent Customer"; myBoolCol.Width = 125; myTableStyle1.GridColumnStyles.Add(myBoolCol); // Create the second table style with columns. DataGridTableStyle myTableStyle2 = new DataGridTableStyle(); myTableStyle2.MappingName = "Orders"; myTableStyle2.AlternatingBackColor = Color.LightBlue; // Create Order Date Column Style. DataGridColumnStyle myOrderDate = new DataGridTextBoxColumn(); myOrderDate.MappingName = "OrderDate"; myOrderDate.HeaderText = "Order Date"; myOrderDate.Width = 100; myTableStyle2.GridColumnStyles.Add(myOrderDate); // Get the PropertyDescriptor of data set. PropertyDescriptorCollection myPCol = this.BindingContext [myDataSet, "Customers.custToOrders"].GetItemProperties(); // Create the Order Amount Column style. DataGridColumnStyle myOrderAmount = new DataGridTextBoxColumn(myPCol["OrderAmount"], "c", true); myOrderAmount.MappingName = "OrderAmount"; myOrderAmount.HeaderText = "Total"; myOrderAmount.Width = 100; myTableStyle2.GridColumnStyles.Add(myOrderAmount); // Add the DataGridTableStyle objects to the GridTableStylesCollection. myDataGrid.TableStyles.Add(myTableStyle1); myDataGrid.TableStyles.Add(myTableStyle2); }
/// <summary> /// Hiligh column of table that they can Edit /// </summary> /// <param name="dt">int put a ref parameter</param> /// <remarks> /// Auther : Cuongvd G3 Fsoft HCM /// created day : 17/01/207 /// </remarks> public void HilighColumn(ref DataGrid grd, System.Drawing.Color color) { if (grd.TableStyles[0].GridColumnStyles.Count <= 0) { return; } DataGridTableStyle grdNew = new DataGridTableStyle(); for (int i = 0; i < grd.TableStyles[0].GridColumnStyles.Count; i++) { if (grd.TableStyles[0].GridColumnStyles[i].ReadOnly == false && (grd.TableStyles[0].GridColumnStyles[i] is DataGridTextBoxColumn)) { DataGridTextBoxColumn colTextBox = (DataGridTextBoxColumn)grd.TableStyles[0].GridColumnStyles[i]; FormattableTextBoxColumn colAdd = new FormattableTextBoxColumn(); colAdd.MappingName = grd.TableStyles[0].GridColumnStyles[i].MappingName; colAdd.Width = grd.TableStyles[0].GridColumnStyles[i].Width; colAdd.ReadOnly = false; colAdd.TextBox.MaxLength = colTextBox.TextBox.MaxLength; RegNumberOnly(colAdd.TextBox); colAdd.NullText = ""; colAdd.HeaderText = grd.TableStyles[0].GridColumnStyles[i].HeaderText; colAdd.SetCellFormat += new FormatCellEventHandler(SetHeaderCellFormat); //arlCol.Add(colAdd); grdNew.GridColumnStyles.Add(colAdd); } else if (grd.TableStyles[0].GridColumnStyles[i] is DataGridBoolColumn) { DataGridBoolColumn colBool = (DataGridBoolColumn)grd.TableStyles[0].GridColumnStyles[i]; FormattableBooleanColumn colBoolAdd = new FormattableBooleanColumn(); colBoolAdd.MappingName = colBool.MappingName; colBoolAdd.ReadOnly = false; colBoolAdd.TrueValue = colBool.TrueValue;; colBoolAdd.FalseValue = colBool.FalseValue;; colBoolAdd.AllowNull = colBool.AllowNull; colBoolAdd.HeaderText = colBool.HeaderText; colBoolAdd.SetCellFormat += new FormatCellEventHandler(SetHeaderCellFormat); //arlCol.Add(colBoolAdd); grdNew.GridColumnStyles.Add(colBoolAdd); } else { grdNew.GridColumnStyles.Add(grd.TableStyles[0].GridColumnStyles[i]); } //arlCol.Add(grd.TableStyles[0].GridColumnStyles[i]); } grdNew.HeaderBackColor = grd.TableStyles[0].HeaderBackColor; grdNew.AlternatingBackColor = grd.TableStyles[0].AlternatingBackColor; grd.TableStyles.RemoveAt(0); grd.TableStyles.Add(grdNew); // foreach(object ojb in arlCol) // { // grd.TableStyles[0].GridColumnStyles.Add(ojb); // } }
public DataGridBoolColumnTests() { DataGridBoolColumn bc = new DataGridBoolColumn(); bc.FalseValueChanged += new System.EventHandler(OnFalseValueChanged); Console.WriteLine("DataGridBoolColumn default --- "); DumpDataGridBoolColumn(bc); bc.FalseValue = true; }
public static DataGridTableStyle GetAttributeTableStyle() { DataGridTableStyle ts = new DataGridTableStyle(); DataGridTextBoxColumn col = null; ts.AllowSorting = false; ts.RowHeadersVisible = false; ts.ReadOnly = true; col = new DataGridTextBoxColumn(); col.MappingName = "Attribute"; col.HeaderText = "Attribute"; col.Width = 180; col.NullText = ""; ts.GridColumnStyles.Add(col); col = new DataGridTextBoxColumn(); col.MappingName = "Type"; col.HeaderText = "Type"; col.Width = 80; col.NullText = ""; ts.GridColumnStyles.Add(col); col = new DataGridTextBoxColumn(); col.MappingName = "Size"; col.HeaderText = "Size"; col.Width = 50; col.NullText = ""; ts.GridColumnStyles.Add(col); col = new DataGridTextBoxColumn(); col.MappingName = "Default"; col.HeaderText = "Default"; col.Width = 100; col.NullText = ""; ts.GridColumnStyles.Add(col); DataGridBoolColumn bcol = new DataGridBoolColumn(); bcol.MappingName = "Required"; bcol.HeaderText = "Required"; bcol.Width = 50; ts.GridColumnStyles.Add(bcol); col = new DataGridTextBoxColumn(); col.MappingName = "Description"; col.HeaderText = "Description"; col.Width = 250; col.NullText = ""; ts.GridColumnStyles.Add(col); return(ts); }
// <Snippet1> // <Snippet2> // <Snippet3> private void AddCustomDataTableStyle() { myDataGridTableStyle1 = new DataGridTableStyle(); // EventHandlers myDataGridTableStyle1.GridLineColorChanged += new System.EventHandler(GridLineColorChanged_Handler); myDataGridTableStyle1.MappingName = "Customers"; // Set other properties. myDataGridTableStyle1.AlternatingBackColor = System.Drawing.Color.Gold; myDataGridTableStyle1.BackColor = System.Drawing.Color.White; myDataGridTableStyle1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.Solid; myDataGridTableStyle1.GridLineColor = Color.Red; // Set the HeaderText and Width properties. DataGridColumnStyle myBoolCol = new DataGridBoolColumn(); myBoolCol.MappingName = "Current"; myBoolCol.HeaderText = "IsCurrent Customer"; myBoolCol.Width = 150; myDataGridTableStyle1.GridColumnStyles.Add(myBoolCol); // Add a second column style. DataGridColumnStyle myTextCol = new DataGridTextBoxColumn(); myTextCol.MappingName = "custName"; myTextCol.HeaderText = "Customer Name"; myTextCol.Width = 250; myDataGridTableStyle1.GridColumnStyles.Add(myTextCol); // Create new ColumnStyle objects DataGridColumnStyle cOrderDate = new DataGridTextBoxColumn(); cOrderDate.MappingName = "OrderDate"; cOrderDate.HeaderText = "Order Date"; cOrderDate.Width = 100; // Use a PropertyDescriptor to create a formatted column. PropertyDescriptorCollection myPropertyDescriptorCollection = BindingContext [myDataSet, "Customers.custToOrders"].GetItemProperties(); // Create a formatted column using a PropertyDescriptor. DataGridColumnStyle csOrderAmount = new DataGridTextBoxColumn(myPropertyDescriptorCollection["OrderAmount"], "c", true); csOrderAmount.MappingName = "OrderAmount"; csOrderAmount.HeaderText = "Total"; csOrderAmount.Width = 100; // Add the DataGridTableStyle instances to the GridTableStylesCollection. myDataGrid.TableStyles.Add(myDataGridTableStyle1); }
protected void InitDGTabStyle() { this.dgM.TableStyles.Clear(); DataGridTableStyle dgTS = new DataGridTableStyle(); dgTS.AllowSorting = false; dgTS.MappingName = "UserRole"; DataGridTextBoxColumn dgColTextBox = null; DataGridDateTimePickerColumn dgColdtPicker = null; DataGridBoolColumn dgColBool = null; dgColBool = new DataGridBoolColumn(); dgColBool.Alignment = HorizontalAlignment.Center; dgColBool.HeaderText = "是否授予"; dgColBool.ReadOnly = false; dgColBool.AllowNull = false; dgColBool.NullValue = 0; dgColBool.Width = 65; dgColBool.TrueValue = 1; dgColBool.FalseValue = 0; dgColBool.MappingName = "RoleGrant"; dgTS.GridColumnStyles.Add(dgColBool); dgColTextBox = new DataGridNoActiveTextBoxColumn(); dgColTextBox.HeaderText = "角色编码"; dgColTextBox.ReadOnly = true; dgColTextBox.Width = 120; dgColTextBox.MappingName = "RoleCode"; dgColTextBox.NullText = string.Empty; dgTS.GridColumnStyles.Add(dgColTextBox); dgColTextBox = new DataGridNoActiveTextBoxColumn(); dgColTextBox.HeaderText = "角色名称"; dgColTextBox.ReadOnly = true; dgColTextBox.Width = 150; dgColTextBox.MappingName = "RoleName"; dgColTextBox.NullText = string.Empty; dgTS.GridColumnStyles.Add(dgColTextBox); dgColdtPicker = new DataGridDateTimePickerColumn(); dgColdtPicker.HeaderText = "gDate"; dgColdtPicker.Width = 0; dgColdtPicker.MappingName = "gDate"; dgColdtPicker.NullText = DateTime.Now.Date.ToShortDateString(); dgTS.GridColumnStyles.Add(dgColdtPicker); this.dgM.TableStyles.Add(dgTS); }
// <Snippet1> // <Snippet2> private void AddCustomDataTableStyle() { myDataGridTableStyle1 = new DataGridTableStyle(); myDataGridTableStyle1.MappingNameChanged += new System.EventHandler(MappingNameChanged_Handler); myDataGridTableStyle1.GridLineStyleChanged += new System.EventHandler(GridLineStyleChanged_Handler); myDataGridTableStyle1.MappingName = "Customers"; // Set other properties. myDataGridTableStyle1.AlternatingBackColor = Color.LightGray; myDataGridTableStyle1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None; // Add a GridColumnStyle and set its MappingName. DataGridColumnStyle myBoolCol = new DataGridBoolColumn(); myBoolCol.MappingName = "Current"; myBoolCol.HeaderText = "IsCurrent Customer"; myBoolCol.Width = 150; myDataGridTableStyle1.GridColumnStyles.Add(myBoolCol); // Add a second column style. DataGridColumnStyle myTextCol = new DataGridTextBoxColumn(); myTextCol.MappingName = "custName"; myTextCol.HeaderText = "Customer Name"; myTextCol.Width = 250; myDataGridTableStyle1.GridColumnStyles.Add(myTextCol); // Create new ColumnStyle objects. DataGridColumnStyle cOrderDate = new DataGridTextBoxColumn(); cOrderDate.MappingName = "OrderDate"; cOrderDate.HeaderText = "Order Date"; cOrderDate.Width = 100; // Use PropertyDescriptor to create a formatted column. PropertyDescriptorCollection myPropertyDescriptorCollection = this.BindingContext [myDataSet, "Customers.custToOrders"].GetItemProperties(); DataGridColumnStyle csOrderAmount = new DataGridTextBoxColumn(myPropertyDescriptorCollection["OrderAmount"], "c", true); csOrderAmount.MappingName = "OrderAmount"; csOrderAmount.HeaderText = "Total"; csOrderAmount.Width = 100; // Add the DataGridTableStyle object to GridTableStylesCollection. myDataGrid.TableStyles.Add(myDataGridTableStyle1); }
public static DataGridTableStyle GetExportEntityOptionsTableStyle() { DataGridTableStyle ts = new DataGridTableStyle(); DataGridTextBoxColumn col = null; DataGridBoolColumn bcol = null; ts.AllowSorting = true; ts.RowHeadersVisible = true; col = new DataGridTextBoxColumn(); col.MappingName = "Entity"; col.HeaderText = "Entity entity"; col.Width = 200; col.NullText = ""; ts.GridColumnStyles.Add(col); col = new DataGridTextBoxColumn(); col.MappingName = "SortNo"; col.HeaderText = "Sort no."; col.Width = 80; col.NullText = ""; ts.GridColumnStyles.Add(col); bcol = new DataGridBoolColumn(); bcol.MappingName = "ExportStructure"; bcol.HeaderText = "Export struct."; bcol.Width = 80; bcol.AllowNull = false; bcol.NullValue = false; ts.GridColumnStyles.Add(bcol); bcol = new DataGridBoolColumn(); bcol.MappingName = "ExportData"; bcol.HeaderText = "Export data"; bcol.Width = 80; bcol.AllowNull = false; bcol.NullValue = false; ts.GridColumnStyles.Add(bcol); bcol = new DataGridBoolColumn(); bcol.MappingName = "ExportDrop"; bcol.HeaderText = "Drop only"; bcol.Width = 80; bcol.AllowNull = false; bcol.NullValue = false; ts.GridColumnStyles.Add(bcol); return(ts); }
public void DumpDataGridBoolColumn(DataGridBoolColumn ts) { Console.WriteLine("AllowNull {0} ", ts.AllowNull); Console.WriteLine("FalseValue {0} ", ts.FalseValue); Console.WriteLine("NullValue {0} ", ts.NullValue); Console.WriteLine("TrueValue {0} ", ts.TrueValue); Console.WriteLine("Alignment {0} ", ts.Alignment); Console.WriteLine("DataGridTableStyle {0} ", ts.DataGridTableStyle); Console.WriteLine("HeaderAccessibleObject {0} ", ts.HeaderAccessibleObject); Console.WriteLine("HeaderText {0} ", ts.HeaderText); Console.WriteLine("MappingName {0} ", ts.NullText); Console.WriteLine("PropertyDescriptor {0} ", ts.PropertyDescriptor); Console.WriteLine("ReadOnly {0} ", ts.ReadOnly); Console.WriteLine("Width {0} ", ts.Width); }
// <Snippet1> private void AddStyleRange() { // Create two DataGridColumnStyle objects. DataGridColumnStyle col1 = new DataGridTextBoxColumn(); col1.MappingName = "FirstName"; DataGridColumnStyle col2 = new DataGridBoolColumn(); col2.MappingName = "Current"; // Create an array and use AddRange to add to collection. DataGridColumnStyle[] cols = new DataGridColumnStyle[2] { col1, col2 }; dataGrid1.TableStyles[0].GridColumnStyles.AddRange(cols); }
public static DataGridTableStyle GetEnumerationTableStyle() { DataGridTableStyle ts = new DataGridTableStyle(); DataGridTextBoxColumn col = null; ts.AllowSorting = false; ts.RowHeadersVisible = false; col = new DataGridTextBoxColumn(); col.MappingName = "ID"; col.HeaderText = "ID"; col.Width = 60; col.NullText = ""; col.ReadOnly = true; ts.GridColumnStyles.Add(col); col = new DataGridTextBoxColumn(); col.MappingName = "Identifier"; col.HeaderText = "Identifier"; col.Width = 180; col.NullText = ""; ts.GridColumnStyles.Add(col); col = new DataGridTextBoxColumn(); col.MappingName = "Name"; col.HeaderText = "Name"; col.Width = 180; col.NullText = ""; ts.GridColumnStyles.Add(col); col = new DataGridTextBoxColumn(); col.MappingName = "Description"; col.HeaderText = "Description"; col.Width = 180; col.NullText = ""; ts.GridColumnStyles.Add(col); DataGridBoolColumn bcol = new DataGridBoolColumn(); bcol.MappingName = "Generate"; bcol.HeaderText = "Generate"; bcol.Width = 60; bcol.AllowNull = false; ts.GridColumnStyles.Add(bcol); return(ts); }
/// <summary> /// Overload 2 Cuongvd /// Without color /// </summary> /// <param name="grd"></param> /// public void HilighColumn(ref DataGrid grd) { if (grd.TableStyles[0].GridColumnStyles.Count <= 0) { return; } DataGridTableStyle grdNew = new DataGridTableStyle(); for (int i = 0; i < grd.TableStyles[0].GridColumnStyles.Count; i++) { if (grd.TableStyles[0].GridColumnStyles[i].ReadOnly == false && (grd.TableStyles[0].GridColumnStyles[i] is DataGridTextBoxColumn)) { DataGridTextBoxColumn colTextbox = (DataGridTextBoxColumn)grd.TableStyles[0].GridColumnStyles[i]; FormattableTextBoxColumn colAdd = new FormattableTextBoxColumn(); colAdd.MappingName = grd.TableStyles[0].GridColumnStyles[i].MappingName; colAdd.ReadOnly = false; colAdd.TextBox.MaxLength = colTextbox.TextBox.MaxLength; colAdd.NullText = colTextbox.NullText; clsCommon.RegNumberOnly(colAdd.TextBox); colAdd.HeaderText = grd.TableStyles[0].GridColumnStyles[i].HeaderText; colAdd.SetCellFormat += new FormatCellEventHandler(SetHeaderCellFormat); //arlCol.Add(colAdd); grdNew.GridColumnStyles.Add(colAdd); } else if (grd.TableStyles[0].GridColumnStyles[i] is DataGridBoolColumn) { DataGridBoolColumn colBool = (DataGridBoolColumn)grd.TableStyles[0].GridColumnStyles[i]; FormattableBooleanColumn colBoolAdd = new FormattableBooleanColumn(); colBoolAdd.MappingName = colBool.MappingName; colBoolAdd.ReadOnly = false; colBoolAdd.TrueValue = colBool.TrueValue;; colBoolAdd.FalseValue = colBool.FalseValue; colBoolAdd.AllowNull = colBool.AllowNull; colBoolAdd.HeaderText = colBool.HeaderText; colBoolAdd.SetCellFormat += new FormatCellEventHandler(SetHeaderCellFormat); grdNew.GridColumnStyles.Add(colBoolAdd); } else { grdNew.GridColumnStyles.Add(grd.TableStyles[0].GridColumnStyles[i]); } } grdNew.HeaderBackColor = grd.TableStyles[0].HeaderBackColor; grd.TableStyles.Clear(); grd.TableStyles.Add(grdNew); }
private void AddCustomDataTableStyle() { myDataGridTableStyle1.ColumnHeadersVisibleChanged += new System.EventHandler(ColumnHeadersVisibleChanged_Handler); // Set ColumnheaderVisible property. myDataGridTableStyle1.MappingName = "Customers"; // Add a GridColumnStyle and set its MappingName DataGridColumnStyle myBoolCol = new DataGridBoolColumn(); myBoolCol.MappingName = "Current"; myBoolCol.HeaderText = "IsCurrent Customer"; myBoolCol.Width = 150; myDataGridTableStyle1.GridColumnStyles.Add(myBoolCol); // Add a second column style. DataGridColumnStyle myTextCol = new DataGridTextBoxColumn(); myTextCol.MappingName = "custName"; myTextCol.HeaderText = "Customer Name"; myTextCol.Width = 250; myDataGridTableStyle1.GridColumnStyles.Add(myTextCol); // Create new ColumnStyle objects DataGridColumnStyle cOrderDate = new DataGridTextBoxColumn(); cOrderDate.MappingName = "OrderDate"; cOrderDate.HeaderText = "Order Date"; cOrderDate.Width = 100; // PropertyDescriptor to create a formatted column. PropertyDescriptorCollection myPropertyDescriptorCollection = this.BindingContext [myDataSet, "Customers.custToOrders"].GetItemProperties(); // Create a formatted column using a PropertyDescriptor. DataGridColumnStyle csOrderAmount = new DataGridTextBoxColumn(myPropertyDescriptorCollection["OrderAmount"], "c", true); csOrderAmount.MappingName = "OrderAmount"; csOrderAmount.HeaderText = "Total"; csOrderAmount.Width = 100; // Add the DataGridTableStyle instances to GridTableStylesCollection. myDataGrid.TableStyles.Add(myDataGridTableStyle1); }
//private void LoadDataGrid(string strSQL,DataGrid dtg) //{ // DataTable dtTable = new DataTable(); // SqlDataAdapter SqlADP = new SqlDataAdapter(strSQL,sqlConn.sqlCNN); // SqlADP.Fill(dtTable); // dtTable.DefaultView.AllowDelete = false; // dtTable.DefaultView.AllowEdit = false; // dtTable.DefaultView.AllowNew = false; // dtg.DataSource = dtTable; //} private void FormatGrid(DataGrid dtg) { DataGridTableStyle dtgTableStyle = new DataGridTableStyle(); dtg.TableStyles.Clear(); //Select DataGridBoolColumn dtgColSelect = new DataGridBoolColumn(); dtgColSelect.MappingName = "Select"; dtgColSelect.HeaderText = "Chọn"; dtgColSelect.NullText = ""; dtgColSelect.Width = 50; dtgColSelect.AllowNull = false; dtgColSelect.Alignment = HorizontalAlignment.Center; //TenDangNhap DataGridTextBoxColumn dtgColTenDangNhap = new DataGridTextBoxColumn(); dtgColTenDangNhap.MappingName = "TenDangNhap"; dtgColTenDangNhap.HeaderText = "Tên Đăng Nhập"; dtgColTenDangNhap.NullText = ""; dtgColTenDangNhap.Width = 90; dtgColTenDangNhap.Alignment = HorizontalAlignment.Center; //MatKhau DataGridTextBoxColumn dtgColMatKhau = new DataGridTextBoxColumn(); dtgColMatKhau.MappingName = "MatKhau"; dtgColMatKhau.HeaderText = "Mật Khẩu"; dtgColMatKhau.NullText = ""; dtgColMatKhau.Width = 70; dtgColMatKhau.Alignment = HorizontalAlignment.Center; //LoaiTaiKhoan DataGridTextBoxColumn dtgColLoaiTaiKhoan = new DataGridTextBoxColumn(); dtgColLoaiTaiKhoan.MappingName = "LoaiTaiKhoan"; dtgColLoaiTaiKhoan.HeaderText = "Loại Tài Khoản"; dtgColLoaiTaiKhoan.NullText = ""; dtgColLoaiTaiKhoan.Width = 90; dtgColLoaiTaiKhoan.Alignment = HorizontalAlignment.Center; dtgTableStyle.GridColumnStyles.AddRange(new DataGridColumnStyle[] { dtgColSelect, dtgColTenDangNhap, dtgColMatKhau, dtgColLoaiTaiKhoan }); dtg.TableStyles.Add(dtgTableStyle); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Login()); DataGridTableStyle ts1 = new DataGridTableStyle(); ts1.MappingName = "Customers"; DataGridBoolColumn myDataCol = new DataGridBoolColumn(); myDataCol.HeaderText = "My New Column"; myDataCol.MappingName = "Current"; ts1.GridColumnStyles.Add(myDataCol); }
private void InitGrid() { // 0 1 2 3 4 5 6 7 8 string[] HeaderText = { "床位号", "加床", "zz_doc", "主治医生", "zy_doc", "管床医生", "charge_nurse", "负责护士", "hoitem_id", "床位费" }; string[] MappingName = { "bed_no", "plus", "zz_doc", "zz_doc_name", "zy_doc", "zy_doc_name", "charge_nurse", "nurse_name", "hoitem_id", "hoitem_name" }; int[] ColWidth = { 50, 35, 0, 75, 0, 75, 0, 60, 0, 300 }; int[] Style = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; DataTable dtTmp = new DataTable(); for (int i = 0; i <= HeaderText.Length - 1; i++) { if (Style[i] == 0) { DataGridEnableTextBoxColumn colText = new DataGridEnableTextBoxColumn(i); colText.HeaderText = HeaderText[i]; colText.MappingName = MappingName[i]; colText.Width = ColWidth[i]; colText.NullText = ""; colText.CheckCellEnabled += new DataGridEnableTextBoxColumn.EnableCellEventHandler(colText_CheckCellEnabled); this.dtgrdBed.TableStyles[0].GridColumnStyles.Add(colText); } else { DataGridBoolColumn boolCol = new DataGridBoolColumn(); boolCol.HeaderText = HeaderText[i]; boolCol.MappingName = MappingName[i]; boolCol.Width = ColWidth[i]; boolCol.NullValue = (short)0; boolCol.TrueValue = (short)1; boolCol.FalseValue = (short)0; boolCol.ReadOnly = true; this.dtgrdBed.TableStyles[0].GridColumnStyles.Add(boolCol); } DataColumn colData = new DataColumn(MappingName[i]); if (Style[i] == 1) { colData.DefaultValue = (short)0; colData.DataType = Type.GetType("System.Int16"); } dtTmp.Columns.Add(colData); } this.dtgrdBed.DataSource = dtTmp; }
/// <summary> /// 创建网格显示格式 /// </summary> /// <param name="headerText">列标题字符集</param> /// <param name="columnMappingName">列匹配字段名称字符集</param> /// <param name="columnWidth">列宽度集合</param> /// <param name="isCheckBoxStyle">列式样集合(true:CheckBoxStyle,false:TextBoxStyle)</param> public void CreateTableStyle(string[] headerText, string[] columnMappingName, int[] columnWidth, bool[] isCheckBoxStyle) { if (headerText != null && columnMappingName != null && columnWidth != null) { if (headerText.Length == columnMappingName.Length && headerText.Length == columnWidth.Length) { //先清空现有格式 this.TableStyles.Clear(); DataGridTextBoxColumn aColumnTextColumn; DataGridTableStyle dtgrdTbStyle = new DataGridTableStyle(); dtgrdTbStyle.AllowSorting = this.AllowSorting; dtgrdTbStyle.ReadOnly = this.ReadOnly; this.TableStyles.Add(dtgrdTbStyle); for (int i = 0; i < headerText.Length; i++) { if (!isCheckBoxStyle[i]) { aColumnTextColumn = new DataGridTextBoxColumn(); aColumnTextColumn.NullText = ""; aColumnTextColumn.HeaderText = headerText[i]; aColumnTextColumn.MappingName = columnMappingName[i]; aColumnTextColumn.Width = columnWidth[i]; this.TableStyles[0].GridColumnStyles.Add(aColumnTextColumn); } else { DataGridBoolColumn colBool = new DataGridBoolColumn(); colBool.HeaderText = headerText[i]; colBool.MappingName = columnMappingName[i]; colBool.NullValue = (short)0; colBool.TrueValue = (short)1; colBool.FalseValue = (short)0; colBool.Width = columnWidth[i]; this.TableStyles[0].GridColumnStyles.Add(colBool); } } } } }
public static DataGridTableStyle GenerateStyle(Type t, string[] displayPropertyNames) { DataGridTableStyle dgts = QMDataGrid.GenerateCommonDataGridTableStyle(); if (displayPropertyNames != null) { PropertyInfo[] propertyInfos = t.GetProperties(); foreach (string displayPropertyName in displayPropertyNames) { foreach (PropertyInfo property in propertyInfos) { if (property.Name != displayPropertyName) { continue; } else { DataGridColumnStyle dgcs = null; if (property.PropertyType == typeof(bool)) { dgcs = new DataGridBoolColumn(); } else { dgcs = new DataGridTextBoxColumn(); dgcs.Width = 200; } dgcs.MappingName = property.Name; dgcs.HeaderText = DataGridDictionary.Instance.GetDataGridPropertyTitle(string.Format("{0}.{1}", t.FullName, property.Name)); dgts.GridColumnStyles.Add(dgcs); break; } } } } return(dgts); }
private void SelectAllDefinitionFiles() { int tempCount = 0; DataGridBoolColumn dataBoolColumn = new DataGridBoolColumn(); foreach (DefinitionFile theDefinitionFile in _DefinitionFilesInfoForDataGrid) { // Get the column style for the "loaded" column. DataGridColumnStyle theColStyle = DataGridSpecifySopClasses.TableStyles[0].GridColumnStyles[0]; // Change the "loaded" stated in _DefinitionFilesInfoForDataGrid and the data grid itself. DataGridSpecifySopClasses.BeginEdit(theColStyle, tempCount); theDefinitionFile.Loaded = true; DataGridSpecifySopClasses.EndEdit(theColStyle, tempCount, false); string theFullFileName = System.IO.Path.Combine(theDefinitionFile.DefinitionRoot, theDefinitionFile.Filename); theSession.DefinitionManagement.LoadDefinitionFile(theFullFileName); tempCount++; } DataGridSpecifySopClasses.SetDataBinding(_DefinitionFilesInfoForDataGrid, ""); }
public Form1() { InitializeComponent(); DataGridBoolColumn myDataCol = new DataGridBoolColumn(); myDataCol.HeaderText = "My New Column"; myDataCol.MappingName = "Current"; string path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); dataGridInit(); HID.MouseAction += MouseHook_MouseAction; HID.KeyboardAction += HIDHook_KeyboardAction; PrevMousePos = HID.MousePos; PrevMousetime = DateTime.Now; this.FormClosing += Form1_FormClosing; this.Resize += Form1_Resize; notifyIcon1.Visible = true; this.notifyIcon1.MouseDoubleClick += NotifyIcon1_MouseDoubleClick; toolStripMenuItem1.Click += ToolStripMenuItem1_Click; }
private void frmRepRMDesp_Load(object sender, EventArgs e) { this.dtpFechaDesde.Value = DateAndTime.get_Now(); this.dtpFechaHasta.Value = DateAndTime.get_Now(); string connectionString = "data source=" + Variables.gServer + ";user id=teleprinter;password=tele;initial catalog=Colector;persist security info=False;packet size=4096"; string str4 = connectionString; SqlConnection connection2 = new SqlConnection(connectionString); connection2.Open(); SqlCommand command = new SqlCommand("delete " + Variables.gTermi + "TmpMetEnvio", connection2); try { command.ExecuteNonQuery(); } catch (Exception exception1) { ProjectData.SetProjectError(exception1); Exception exception = exception1; Interaction.MsgBox("Se ha producido el siguiente error:" + exception.Message, 0, null); connection2.Close(); ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } SqlConnection connection = new SqlConnection("data source=" + Variables.gServer + ";user id=scala;password=scala;initial catalog=scalaDB;persist security info=True;packet size=4096"); connection.Open(); string cmdText = "SELECT SL23003+'-'+SL23004 as MetEnv,SL23003 FROM dbo.SL230100 where SL23001='2' and SL23002='00' order by MetEnv"; command = new SqlCommand(cmdText, connection); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { command = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("insert into " + Variables.gTermi + "TmpMetEnvio (MetEnvio,Seleccion) values ('", reader["MetEnv"]), "',1)")), connection2); try { command.ExecuteNonQuery(); } catch (Exception exception3) { ProjectData.SetProjectError(exception3); Exception exception2 = exception3; Interaction.MsgBox("Se ha producido el siguiente error:" + exception2.Message, 0, null); reader.Close(); connection.Close(); connection2.Close(); ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } } reader.Close(); connection.Close(); connection2.Close(); connectionString = "data source=" + Variables.gServer + ";user id=teleprinter;password=tele;initial catalog=Colector;persist security info=False;packet size=4096"; string selectCommandText = "select * from " + Variables.gTermi + "TmpMetEnvio order by MetEnvio"; this.AdapTmp = new SqlDataAdapter(selectCommandText, connectionString); this.CB = new SqlCommandBuilder(this.AdapTmp); this.AdapTmp.Fill(this.DS, Variables.gTermi + "TmpMetEnvio"); this.dgMetEnvio.DataSource = this.DS.Tables[Variables.gTermi + "TmpMetEnvio"]; DataGridTableStyle table = new DataGridTableStyle(); table.MappingName = Variables.gTermi + "TmpMetEnvio"; DataGridTextBoxColumn column = new DataGridTextBoxColumn(); DataGridBoolColumn column2 = new DataGridBoolColumn(); DataGridBoolColumn column4 = column2; column4.HeaderText = "Sel."; column4.MappingName = "Seleccion"; column4.Width = 0x23; column4 = null; table.GridColumnStyles.Add(column2); column = new DataGridTextBoxColumn(); DataGridTextBoxColumn column3 = column; column3.HeaderText = "Metodo Env\x00edo"; column3.MappingName = "MetEnvio"; column3.ReadOnly = true; column3.Width = 390; column3 = null; table.GridColumnStyles.Add(column); this.dgMetEnvio.TableStyles.Add(table); this.dgMetEnvio.Refresh(); }
private void AddCustomDataTableStyle() { DataGridTableStyle ts1 = new DataGridTableStyle(); ts1.MappingName = "Customers"; // Set other properties. ts1.AlternatingBackColor = Color.LightGray; /* Add a GridColumnStyle and set its MappingName * to the name of a DataColumn in the DataTable. * Set the HeaderText and Width properties. */ DataGridColumnStyle boolCol = new DataGridBoolColumn(); boolCol.MappingName = "Current"; boolCol.HeaderText = "IsCurrent Customer"; boolCol.Width = 150; ts1.GridColumnStyles.Add(boolCol); // Add a second column style. DataGridColumnStyle TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "custName"; TextCol.HeaderText = "Customer Name"; TextCol.Width = 250; ts1.GridColumnStyles.Add(TextCol); // Create the second table style with columns. DataGridTableStyle ts2 = new DataGridTableStyle(); ts2.MappingName = "Orders"; // Set other properties. ts2.AlternatingBackColor = Color.LightBlue; // Create new ColumnStyle objects DataGridColumnStyle cOrderDate = new DataGridTextBoxColumn(); cOrderDate.MappingName = "OrderDate"; cOrderDate.HeaderText = "Order Date"; cOrderDate.Width = 100; ts2.GridColumnStyles.Add(cOrderDate); /* Use a PropertyDescriptor to create a formatted * column. First get the PropertyDescriptorCollection * for the data source and data member. */ PropertyDescriptorCollection pcol = this.BindingContext [myDataSet, "Customers.custToOrders"].GetItemProperties(); /* Create a formatted column using a PropertyDescriptor. * The formatting character "c" specifies a currency format. */ DataGridColumnStyle csOrderAmount = new DataGridTextBoxColumn(pcol["OrderAmount"], "c", true); csOrderAmount.MappingName = "OrderAmount"; csOrderAmount.HeaderText = "Total"; csOrderAmount.Width = 100; ts2.GridColumnStyles.Add(csOrderAmount); /* Add the DataGridTableStyle instances to * the GridTableStylesCollection. */ myDataGrid.TableStyles.Add(ts1); myDataGrid.TableStyles.Add(ts2); // Sets the TablesAlreadyAdded to true so this doesn't happen again. TablesAlreadyAdded = true; }
private void StartForm_Load(object sender, System.EventArgs e) { // Einlesen der Products-Tabelle der Northwind-Datenbank string server = ConfigurationSettings.AppSettings["server"]; SqlConnection connection = new SqlConnection("Server=" + server + ";Database=Northwind;Trusted_Connection=Yes"); try { connection.Open(); } catch (Exception ex) { MessageBox.Show("Fehler beim Verbindungsaufbau zur Northwind-" + "Datenbank:" + ex.Message + "\r\nKontrollieren Sie die " + "Einstellungen in der Anwendungskonfiguration", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT ProductId, " + "ProductName, Discontinued FROM Products", connection); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet, "Products"); // DataGridTableStyle-Objekt erzeugen und initialisieren DataGridTableStyle tableStyle = new DataGridTableStyle(); tableStyle.MappingName = "Products"; // Spalten des DataSet definieren DataGridTextBoxColumn col1 = new ExtDataGridTextBoxColumn(); col1.HeaderText = "Artikel-Nr"; col1.MappingName = "ProductId"; col1.Width = 70; col1.ReadOnly = true; tableStyle.GridColumnStyles.Add(col1); DataGridTextBoxColumn col2 = new ExtDataGridTextBoxColumn(); col2.HeaderText = "Artikelname"; col2.MappingName = "ProductName"; col2.Width = 150; tableStyle.GridColumnStyles.Add(col2); DataGridBoolColumn col3 = new DataGridBoolColumn(); col3.HeaderText = "Auslaufartikel"; col3.MappingName = "Discontinued"; col3.AllowNull = false; // Dreiwertigkeit unterbinden col3.Width = 80; tableStyle.GridColumnStyles.Add(col3); // DataGridTableStyle-Instanz dem DataGrid zuweisen this.productsGrid.TableStyles.Add(tableStyle); // DataSet an das DataGrid anbinden this.productsGrid.DataMember = "Products"; this.productsGrid.DataSource = dataSet; }