public MainForm () { _dataGrid = new DataGrid (); _column = new DataGridTextBoxColumn (); SuspendLayout (); ((ISupportInitialize) (_dataGrid)).BeginInit (); // // _dataGrid // _dataGrid.TableStyles.Add (new DataGridTableStyle ()); _dataGrid.TableStyles [0].GridColumnStyles.Add (_column); _dataGrid.Location = new Point (12, 115); _dataGrid.Size = new Size (268, 146); _dataGrid.TabIndex = 0; // // _column // _column.HeaderText = "Column"; // // MainForm // ClientSize = new Size (292, 273); Controls.Add (_dataGrid); ((ISupportInitialize) (_dataGrid)).EndInit (); ResumeLayout (false); Load += new EventHandler (MainForm_Load); }
public Frm() { DataTable table = new DataTable(); DataColumn column1 = new DataColumn(); DataGrid grid = new DataGrid(); table.Rows.Add(); grid.Dock = DockStyle.Fill; table.Columns.Add(column1); Controls.Add(grid); DataGridTableStyle tableStyle = new DataGridTableStyle(); DataGridColumnStyle colStyle = new DataGridTextBoxColumn(); // colStyle.MappingName = "Column1"; tableStyle.GridColumnStyles.Add(colStyle); grid.TableStyles.Add(tableStyle); grid.DataSource = table; table.Columns.Add("another hidden column"); }
/// <summary> /// /// </summary> private void DataGridTitle() { DataGridTableStyle tbs = new DataGridTableStyle(); DataGridTextBoxColumn clm = new DataGridTextBoxColumn(); clm = new DataGridTextBoxColumn(); clm.MappingName = "name"; clm.HeaderText = "站名称"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "team"; clm.HeaderText = "所属班组"; clm.Width = 100; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "heatArea"; clm.HeaderText = "供热面积" + "\n(" + "万平方米" + ")"; clm.Width = 100; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "oneGivePress"; clm.HeaderText = "一次供水压力" + "\n(" + "Mpa" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "oneBackPress"; clm.HeaderText = "一次回水压力" + "\n(" + "Mpa" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "oneGiveTemp"; clm.HeaderText = "一次供水温度" + "\n(" + "C" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "oneBackTemp"; clm.HeaderText = "一次回水温度" + "\n(" + "C" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "oneTempCha"; clm.HeaderText = "一次供回水温差" + "\n(" + "C" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "oneAccum"; clm.HeaderText = "流量" + "\n(" + "T" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "YestOneAccum"; clm.HeaderText = "前日流量" + "\n(" + "T" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "twoGivePress"; clm.HeaderText = "二次供水压力" + "\n(" + "Mpa" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "twoBackPress"; clm.HeaderText = "二次回水压力" + "\n(" + "Mpa" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "twoGiveTemp"; clm.HeaderText = "二次供水温度" + "\n(" + "C" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "twoBackTemp"; clm.HeaderText = "二次回水温度" + "\n(" + "C" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "addPumpValue"; clm.HeaderText = "自来水流量" + "\n(" + "T" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "YestAddPumpValue"; clm.HeaderText = "前日自来水流量" + "\n(" + "T" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "AddWat"; clm.HeaderText = "补水量" + "\n(" + "T" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "MissWat"; clm.HeaderText = "失水率"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "DayHeat"; clm.HeaderText = "日耗热量" + "\n(" + "GJ" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "AvgHeat"; clm.HeaderText = "每万平方米耗热量" + "\n(" + "C" + ")"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); clm = new DataGridTextBoxColumn(); clm.MappingName = "name1"; clm.HeaderText = "站名称"; clm.Width = 120; tbs.GridColumnStyles.Add(clm); tbs.MappingName = "RMDayReport"; m_dataGrid.TableStyles.Add(tbs); m_dataGrid.HeaderFont = new Font("Arial", 15); }
private void AddGridTableStyle() { DataGridTableStyle ts = new DataGridTableStyle(); ts.MappingName = dtct.TableName; ts.AlternatingBackColor = Color.Beige; ts.BackColor = Color.GhostWhite; ts.ForeColor = Color.MidnightBlue; ts.GridLineColor = Color.RoyalBlue; ts.HeaderBackColor = Color.MidnightBlue; ts.HeaderForeColor = Color.Lavender; ts.SelectionBackColor = Color.Teal; ts.SelectionForeColor = Color.PaleGreen; ts.ReadOnly = false; ts.RowHeaderWidth = 5; DataGridTextBoxColumn TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "stt"; TextCol.HeaderText = ""; TextCol.Width = 0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "doituong"; TextCol.HeaderText = ""; TextCol.Width = 0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "ma"; TextCol.HeaderText = "Mã số"; TextCol.Width = 50; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "ten"; TextCol.HeaderText = "Tên"; TextCol.Width = (bGiaban)?200:230; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "tenhc"; TextCol.HeaderText = ""; TextCol.Width = 0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "dang"; TextCol.HeaderText = "ĐVT"; TextCol.Width = 50; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "tenkho"; TextCol.HeaderText = "Kho xuất"; TextCol.Width = 70; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "tennguon"; TextCol.HeaderText = "Nguồn"; TextCol.Width = (ttb.bQuanlynguon(i_nhom))?80:0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "tennhomcc"; TextCol.HeaderText = "Nhà cung cấp"; TextCol.Width = (ttb.bQuanlynhomcc(i_nhom))?90:0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "handung"; TextCol.HeaderText = "Date"; TextCol.Width = (ttb.bQuanlyhandung(i_nhom))?30:0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "losx"; TextCol.HeaderText = "Số hiệu"; TextCol.Width = (ttb.bQuanlylosx(i_nhom))?50:0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "soluong"; TextCol.HeaderText = "Số lượng"; TextCol.Width = 70; TextCol.Format = "#,###,##0.00"; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "dongia"; TextCol.HeaderText = "Đơn giá"; TextCol.Width = 80; TextCol.Format = "###,###,###,##0.000"; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "sotien"; TextCol.HeaderText = "Số tiền"; TextCol.Width = 100; TextCol.Format = "###,###,###,##0.000"; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "giaban"; TextCol.HeaderText = ""; TextCol.Width = 0; TextCol.Format = "###,###,###,##0"; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); }
private void AddGridTableStyle() { DataGridTableStyle ts = new DataGridTableStyle(); ts.MappingName = dt.TableName; ts.AlternatingBackColor = Color.Beige; ts.BackColor = Color.GhostWhite; ts.ForeColor = Color.MidnightBlue; ts.GridLineColor = Color.RoyalBlue; ts.HeaderBackColor = Color.MidnightBlue; ts.HeaderForeColor = Color.Lavender; ts.SelectionBackColor = Color.Teal; ts.SelectionForeColor = Color.PaleGreen; ts.ReadOnly = false; ts.RowHeaderWidth = 10; DataGridTextBoxColumn TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "tennguon"; TextCol.HeaderText = "Nguồn"; TextCol.Width = (d.bQuanlynguon(i_nhom))?80:0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "tennhomcc"; TextCol.HeaderText = "Nhà cung cấp"; TextCol.Width = (d.bQuanlynhomcc(i_nhom))?150:0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "ma"; TextCol.HeaderText = "Mã số"; TextCol.Width = 50; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "tenbd"; TextCol.HeaderText = "Tên"; TextCol.Width = 200; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "tenhc"; TextCol.HeaderText = "Hoạt chất"; TextCol.Width = (d.bHoatchat)?200:0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "dang"; TextCol.HeaderText = "ĐVT"; TextCol.Width = 50; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "handung"; TextCol.HeaderText = "Date"; TextCol.Width = (d.bQuanlyhandung(i_nhom))?30:0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "losx"; TextCol.HeaderText = "Lô SX"; TextCol.Width = (d.bQuanlylosx(i_nhom))?50:0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "giamua"; TextCol.HeaderText = "Đơn gía"; TextCol.Width = 80; TextCol.Format = format_dongia; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "tondau"; TextCol.HeaderText = "Tồn đầu"; TextCol.Width = 80; TextCol.Format = format_soluong; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "sttondau"; TextCol.HeaderText = ""; TextCol.Width = 0; TextCol.Format = format_sotien; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "slnhap"; TextCol.HeaderText = "Vay"; TextCol.Width = 80; TextCol.Format = format_soluong; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "stnhap"; TextCol.HeaderText = ""; TextCol.Width = 0; TextCol.Format = format_sotien; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "slxuat"; TextCol.HeaderText = "Quyết toán"; TextCol.Width = 80; TextCol.Format = format_soluong; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "stxuat"; TextCol.HeaderText = ""; TextCol.Width = 0; TextCol.Format = format_sotien; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "toncuoi"; TextCol.HeaderText = "Tồn cuối"; TextCol.Width = 80; TextCol.Format = format_soluong; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "sttoncuoi"; TextCol.HeaderText = ""; TextCol.Width = 0; TextCol.Format = format_sotien; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "giaban"; TextCol.HeaderText = (bGiaban)?"Giá bán":""; TextCol.Width = (bGiaban)?100:0; TextCol.Format = "###,###,###,##0"; TextCol.Alignment = HorizontalAlignment.Right; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); }
public void updateUI() { /** Handles for holding controls while filling them in **/ TextBox tb; Label lbl; ComboBox cb; /** We don't care about the association of optionid to optioninfo just the info **/ var ops = options.Values; /** The vertical multiplier (essentially how many control have been generated into the * current column. **/ int yMultiplier = 0; /** Which column are we generating **/ int columnNumber = 1; /** The total number of columns **/ const int totalColumns = 3; const int columnTopBottomPadding = 16; const int columnWidth = 350; const int columnLRPadding = 10; const int datagridHeight = 120; const int labelWidth = 160; const int labelHeight = 20; const int controlHeight = 20; const int controlWidth = columnWidth - labelWidth; const int rowBottomPadding = 10; const int rowHeight = controlHeight + rowBottomPadding; /** Vertical offset from the fixed start coordinarte **/ int yOffset = columnTopBottomPadding; /** Horizontal offset from the fixed start coordinarte **/ int xOffset = columnLRPadding; /** Decide if now is the time to switch to a new column. **/ bool splitColumn; /** Lets save some time and wait until the end to draw all this! **/ SuspendLayout(); /** Increment the index and the multiplier each iteration (so that the multiplier * can reset at start of column 2 **/ /** i . The current index into the option array **/ int i = 0; foreach (var option in options.Values) { splitColumn = columnNumber < totalColumns && i - 1 >= columnNumber * (ops.Count / totalColumns); /** * If splitting to new column or if we've reached the end of the last column * check if we need to make the window height larger based on the last row's contents **/ if (splitColumn || (i == ops.Count - 1)) { /** Set the form height to the height of the first column **/ int newHeight = (rowHeight * yMultiplier) + status.Height + (2 * columnTopBottomPadding); if (newHeight > Height) { Height = newHeight; } } /** When half the controls have been generated move onto the second column * WORK NEEDED: a better method of splitting controls into columns, eg. half * the options != half space on screen due to indexed options. **/ if (splitColumn) { /** Place the statusBar correctly after resize **/ status.Top = yOffset + (rowHeight * yMultiplier) + columnTopBottomPadding; /** Move the buttons to a sensible place **/ int buttonTopOffset = yOffset + (rowHeight * yMultiplier) + (2 * columnTopBottomPadding); saveButton.Location = new System.Drawing.Point(columnLRPadding, buttonTopOffset); cancelButton.Location = new System.Drawing.Point(saveButton.Right + 10, buttonTopOffset); restartButton.Location = new System.Drawing.Point(cancelButton.Right + 10, buttonTopOffset); /** New horizontal offset to represent next column **/ xOffset = (columnNumber * (columnWidth + columnLRPadding)) + columnLRPadding; /** Back to the top row **/ yMultiplier = 0; /** We are now on the next **/ columnNumber++; /** Set the offset to the same value as originally **/ yOffset = columnTopBottomPadding; } /** Indexed options must be treated differently, they are placed into datagrids **/ if (option.isIndexed()) { /** This needs to be done using a datagrid so that we can have indexable * settings for it. **/ /** If this is the first option for this set of indexed options (options based on * the same maximum index value then there will be no datagrid already so we * make one. **/ /** Create a handle for the datagrid and datatable **/ DataGrid dg; System.Data.DataTable dt; if (!indexControls.ContainsKey(option.getGroupid())) { dg = new DataGrid(); /** Create a table style for the datagrid **/ var dgts = new DataGridTableStyle(); /** Taken from the forms designer... assumed to be needed **/ ((System.ComponentModel.ISupportInitialize)dg).BeginInit(); dg.DataMember = ""; dg.HeaderForeColor = System.Drawing.SystemColors.ControlText; /** Use the horizontal and vertical attributes to place the control correctly **/ dg.Location = new System.Drawing.Point(xOffset, yOffset + (rowHeight * yMultiplier)); /** The control refers to the group of options and is so named **/ dg.Name = string.Concat("groupOption", option.getGroupid().ToString()); /** Set the size of the entire grid. **/ dg.Size = new System.Drawing.Size(columnWidth, datagridHeight); /** Account for the size of the datagrid, so that the next control boxes don't draw ontop of it **/ yOffset += datagridHeight + rowBottomPadding - rowHeight; /** WORK NEEDED: tabindex counter **/ dg.TabIndex = 2; dg.TableStyles.Add(dgts); /** Hide the description bit at the top, it serves no purpose **/ dg.CaptionVisible = false; /** link the grid and the gridstyle **/ dgts.DataGrid = dg; dgts.HeaderForeColor = System.Drawing.SystemColors.ControlText; dgts.MappingName = ""; /** Add it to the form controls **/ Controls.Add(dg); ((System.ComponentModel.ISupportInitialize)dg).EndInit(); /** Finished basic datagrid initialization **/ /** Create a datatable to hold all the info for this set of options **/ dt = new System.Data.DataTable(); /** Add an index column so that visually we can see which index we are editing **/ dt.Columns.Add("index", Type.GetType("System.Int32")); dt.Columns["index"].ReadOnly = true; /** Add a column style so that the column created above can be seen **/ var tbc = new DataGridTextBoxColumn { HeaderText = "", /** map it onto the index field **/ MappingName = "index", /** It is only a 1 or 2 digit number **/ Width = 20 }; /** Add the style onto the grid **/ dg.TableStyles[0].GridColumnStyles.Add(tbc); /** Make a dataview for the datatable so that we cant delete or create new rows * rows are deleted or created by altering the value of the option controlling * the number of indices **/ var dv = new System.Data.DataView(dt) { AllowNew = false, AllowDelete = false }; dg.SetDataBinding(dv, ""); /** Add the datagrid and table to the hashtable so that future options in * the same group can reuse them **/ indexControls.Add(option.getGroupid(), new IndexControlsLookup(dg, dt)); } else { /** Get the datatable and the grid out of the cache and effectively remove an item * from the column by backing up the vertical offset by the row height (the same value as * the multiplier's multiplicand) **/ var icl = indexControls[option.getGroupid()]; dt = icl.dt; dg = icl.dg; yOffset -= rowHeight; } /** Each option type has to be treated differently as it is stored differently in the datatable **/ switch ((ConfigType)option.getType()) { case ConfigType.Str: { /** Strings are stored as... strings **/ dt.Columns.Add(option.getDescription(), typeof(string)); /** In... textboxes **/ var tbc = new DataGridTextBoxColumn { /** The description is used as the field name. WORK NEEDED: this could cause * bugs, consider using the optionid **/ HeaderText = option.getDescription(), MappingName = option.getDescription() }; dg.TableStyles[0].GridColumnStyles.Add(tbc); } break; case ConfigType.Int: { /** Integers are stored as... integers **/ dt.Columns.Add(option.getDescription(), typeof(int)); /** In text boxes... WORK NEEDED: perhaps add a textchanged event to validate it being a number **/ var tbc = new DataGridTextBoxColumn { /** Same rules as above **/ HeaderText = option.getDescription(), MappingName = option.getDescription() }; dg.TableStyles[0].GridColumnStyles.Add(tbc); } break; case ConfigType.Choice: { /** Choice types are stored as integers as well because we refer to the choice index not the value **/ dt.Columns.Add(option.getDescription(), typeof(int)); var cbc = new BAPSPresenter.DataGridComboBoxColumn { HeaderText = option.getDescription(), MappingName = option.getDescription(), Width = 200 }; dg.TableStyles[0].GridColumnStyles.Add(cbc); /** In order for the combo box to receive its values it has to be exposed * DO NOT MESS WITH IT.. AT ALL **/ option.setComboBoxControl(cbc.getComboBox()); } break; } /** The option needs to know where its data is stored, it assumes it will have a valid * handle to a datatable if it is an indexed option **/ option.setDataTable(dt); } else { /** NON INDEXED options **/ /** The non indexed options have labels to describe them **/ lbl = new Label { /** Place the label according to the horizontal and vertical rules **/ Location = new System.Drawing.Point(xOffset, yOffset + ((controlHeight + rowBottomPadding) * yMultiplier)), Name = string.Concat("optionLabel", option.getOptionid().ToString()), Size = new System.Drawing.Size(labelWidth, labelHeight), TabStop = false, /** The label contains the option description **/ Text = option.getDescription() }; /** For completeness the option is told what its label handle is **/ option.setLabelControl(lbl); /** Add the label to the form **/ Controls.Add(lbl); switch ((ConfigType)option.getType()) { case ConfigType.Str: case ConfigType.Int: { /** String and integer options can be treated the same (For now) * WORK NEEDED: validate entries to integer text boxes to ensure they are integers **/ tb = new TextBox { /** Place the textbox according to the horizontal and vertical rules **/ Location = new System.Drawing.Point(labelWidth + xOffset, yOffset + ((controlHeight + rowBottomPadding) * yMultiplier)), Name = string.Concat("optionBox", option.getOptionid().ToString()), Size = new System.Drawing.Size(controlWidth, controlHeight), /** WORK NEEDED: tab indices **/ TabIndex = option.getOptionid(), /** Start with the control disabled and with set-me as its text to show it * has not received a value from the server (useful ofr debugging only) **/ Text = "[set-me]", /** The control knows what option it refers to... unused for now maybe **/ Tag = option }; /** Inform the option what control it is hosted in **/ option.setTextBoxControl(tb); tb.Enabled = true; /** Show the control on the form **/ Controls.Add(tb); } break; case ConfigType.Choice: { cb = new ComboBox { /** Place the textbox according to the horizontal and vertical rules **/ Location = new System.Drawing.Point(labelWidth + xOffset, yOffset + ((controlHeight + rowBottomPadding) * yMultiplier)), Name = string.Concat("optionBox", option.getOptionid().ToString()), Size = new System.Drawing.Size(controlWidth, controlHeight), /** WORK NEEDED: tab indices **/ TabIndex = option.getOptionid(), /** The control knows what option it refers to... unused for now maybe **/ Tag = option, /** Make it uneditable **/ DropDownStyle = ComboBoxStyle.DropDownList }; /** Inform the option what control it is hosted in **/ option.setComboBoxControl(cb); /** Disable the control to start with (so it cannot be set until the server * has sent its current value **/ cb.Enabled = true; /** Show the control on the form **/ Controls.Add(cb); } break; } } i++; yMultiplier++; } /** Get the required height for column 2 (same equation as used after end of column 1) **/ int minHeight = 28 + yOffset + (24 * (yMultiplier + 1)) + status.Height + 32; /** If the height of the form is less that what is needed resize as above **/ if (Height < minHeight) { Height = minHeight; status.Top = yOffset + 24 * (yMultiplier + 1) + 32; saveButton.Top = yOffset + (24 * yMultiplier) + 4; restartButton.Top = yOffset + (24 * yMultiplier) + 4; cancelButton.Top = yOffset + (24 * yMultiplier) + 4; } Width = totalColumns * (columnWidth + 2 * columnLRPadding); /** Show all the controls that have just been made **/ ResumeLayout(false); PerformLayout(); /** Attempt to receive all the settings (will not happen if there are outstanding choices * for some of the CHOICE type options still to receive) **/ receiveSettingsIfReady(); }
/// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Frmtitle)); this.panel1 = new System.Windows.Forms.Panel(); this.panel5 = new System.Windows.Forms.Panel(); this.buttask = new System.Windows.Forms.Button(); this.myDataGrid1 = new myDataGrid.myDataGrid(); this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle(); this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn5 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn6 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn(); this.panel4 = new System.Windows.Forms.Panel(); this.butsh = new System.Windows.Forms.Button(); this.butclose = new System.Windows.Forms.Button(); this.statusBar1 = new System.Windows.Forms.StatusBar(); this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel(); this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel(); this.butnew = new System.Windows.Forms.Button(); this.panel3 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel(); this.cmbck = new System.Windows.Forms.ComboBox(); this.label3 = new System.Windows.Forms.Label(); this.dtp2 = new System.Windows.Forms.DateTimePicker(); this.label1 = new System.Windows.Forms.Label(); this.dtp1 = new System.Windows.Forms.DateTimePicker(); this.chkdjsj = new System.Windows.Forms.CheckBox(); this.butref = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.panel5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.myDataGrid1)).BeginInit(); this.panel4.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit(); this.panel3.SuspendLayout(); this.panel2.SuspendLayout(); this.SuspendLayout(); // // panel1 // this.panel1.Controls.Add(this.panel5); this.panel1.Controls.Add(this.panel4); this.panel1.Controls.Add(this.panel3); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(832, 485); this.panel1.TabIndex = 0; // // panel5 // this.panel5.Controls.Add(this.buttask); this.panel5.Controls.Add(this.myDataGrid1); this.panel5.Dock = System.Windows.Forms.DockStyle.Fill; this.panel5.Location = new System.Drawing.Point(0, 64); this.panel5.Name = "panel5"; this.panel5.Size = new System.Drawing.Size(832, 365); this.panel5.TabIndex = 3; // // buttask // this.buttask.Image = ((System.Drawing.Image)(resources.GetObject("buttask.Image"))); this.buttask.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.buttask.Location = new System.Drawing.Point(280, 104); this.buttask.Name = "buttask"; this.buttask.Size = new System.Drawing.Size(288, 40); this.buttask.TabIndex = 1; this.buttask.Text = "正在加载数据,请稍后..........."; this.buttask.Visible = false; // // myDataGrid1 // this.myDataGrid1.BackgroundColor = System.Drawing.Color.White; this.myDataGrid1.CaptionVisible = false; this.myDataGrid1.DataMember = ""; this.myDataGrid1.Dock = System.Windows.Forms.DockStyle.Fill; this.myDataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.myDataGrid1.Location = new System.Drawing.Point(0, 0); this.myDataGrid1.Name = "myDataGrid1"; this.myDataGrid1.ReadOnly = true; this.myDataGrid1.Size = new System.Drawing.Size(832, 365); this.myDataGrid1.TabIndex = 0; this.myDataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] { this.dataGridTableStyle1 }); this.myDataGrid1.DoubleClick += new System.EventHandler(this.myDataGrid1_DoubleClick); this.myDataGrid1.CurrentCellChanged += new System.EventHandler(this.myDataGrid1_CurrentCellChanged); // // dataGridTableStyle1 // this.dataGridTableStyle1.AllowSorting = false; this.dataGridTableStyle1.DataGrid = this.myDataGrid1; this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] { this.dataGridTextBoxColumn1, this.dataGridTextBoxColumn3, this.dataGridTextBoxColumn4, this.dataGridTextBoxColumn5, this.dataGridTextBoxColumn6, this.dataGridTextBoxColumn2 }); this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGridTableStyle1.ReadOnly = true; // // dataGridTextBoxColumn1 // this.dataGridTextBoxColumn1.Format = ""; this.dataGridTextBoxColumn1.FormatInfo = null; this.dataGridTextBoxColumn1.HeaderText = "序号"; this.dataGridTextBoxColumn1.NullText = ""; this.dataGridTextBoxColumn1.ReadOnly = true; this.dataGridTextBoxColumn1.Width = 60; // // dataGridTextBoxColumn3 // this.dataGridTextBoxColumn3.Format = ""; this.dataGridTextBoxColumn3.FormatInfo = null; this.dataGridTextBoxColumn3.HeaderText = "仓库名称"; this.dataGridTextBoxColumn3.NullText = ""; this.dataGridTextBoxColumn3.Width = 75; // // dataGridTextBoxColumn4 // this.dataGridTextBoxColumn4.Format = ""; this.dataGridTextBoxColumn4.FormatInfo = null; this.dataGridTextBoxColumn4.HeaderText = "单据号"; this.dataGridTextBoxColumn4.NullText = ""; this.dataGridTextBoxColumn4.ReadOnly = true; this.dataGridTextBoxColumn4.Width = 75; // // dataGridTextBoxColumn5 // this.dataGridTextBoxColumn5.Format = ""; this.dataGridTextBoxColumn5.FormatInfo = null; this.dataGridTextBoxColumn5.HeaderText = "审核时间"; this.dataGridTextBoxColumn5.NullText = ""; this.dataGridTextBoxColumn5.ReadOnly = true; this.dataGridTextBoxColumn5.Width = 150; // // dataGridTextBoxColumn6 // this.dataGridTextBoxColumn6.Format = ""; this.dataGridTextBoxColumn6.FormatInfo = null; this.dataGridTextBoxColumn6.HeaderText = "审核员"; this.dataGridTextBoxColumn6.NullText = ""; this.dataGridTextBoxColumn6.ReadOnly = true; this.dataGridTextBoxColumn6.Width = 75; // // dataGridTextBoxColumn2 // this.dataGridTextBoxColumn2.Format = ""; this.dataGridTextBoxColumn2.FormatInfo = null; this.dataGridTextBoxColumn2.HeaderText = "ID"; this.dataGridTextBoxColumn2.NullText = ""; this.dataGridTextBoxColumn2.ReadOnly = true; this.dataGridTextBoxColumn2.Width = 0; // // panel4 // this.panel4.Controls.Add(this.butsh); this.panel4.Controls.Add(this.butclose); this.panel4.Controls.Add(this.statusBar1); this.panel4.Controls.Add(this.butnew); this.panel4.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel4.Location = new System.Drawing.Point(0, 429); this.panel4.Name = "panel4"; this.panel4.Size = new System.Drawing.Size(832, 56); this.panel4.TabIndex = 2; // // butsh // this.butsh.Location = new System.Drawing.Point(450, 6); this.butsh.Name = "butsh"; this.butsh.Size = new System.Drawing.Size(88, 24); this.butsh.TabIndex = 4; this.butsh.Text = "查看(&H)"; this.butsh.Click += new System.EventHandler(this.butsh_Click); // // butclose // this.butclose.Location = new System.Drawing.Point(552, 6); this.butclose.Name = "butclose"; this.butclose.Size = new System.Drawing.Size(88, 24); this.butclose.TabIndex = 3; this.butclose.Text = "关闭(&Q)"; this.butclose.Click += new System.EventHandler(this.butclose_Click); // // statusBar1 // this.statusBar1.Location = new System.Drawing.Point(0, 32); this.statusBar1.Name = "statusBar1"; this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { this.statusBarPanel1, this.statusBarPanel2 }); this.statusBar1.ShowPanels = true; this.statusBar1.Size = new System.Drawing.Size(832, 24); this.statusBar1.TabIndex = 1; this.statusBar1.Text = "statusBar1"; // // statusBarPanel1 // this.statusBarPanel1.Name = "statusBarPanel1"; this.statusBarPanel1.Width = 200; // // statusBarPanel2 // this.statusBarPanel2.Name = "statusBarPanel2"; this.statusBarPanel2.Width = 1000; // // butnew // this.butnew.Location = new System.Drawing.Point(304, 6); this.butnew.Name = "butnew"; this.butnew.Size = new System.Drawing.Size(136, 24); this.butnew.TabIndex = 0; this.butnew.Text = "提取盘点录入数据(&N)"; this.butnew.Click += new System.EventHandler(this.butnew_Click); // // panel3 // this.panel3.Controls.Add(this.panel2); this.panel3.Dock = System.Windows.Forms.DockStyle.Top; this.panel3.Location = new System.Drawing.Point(0, 0); this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(832, 64); this.panel3.TabIndex = 1; // // panel2 // this.panel2.Controls.Add(this.cmbck); this.panel2.Controls.Add(this.label3); this.panel2.Controls.Add(this.dtp2); this.panel2.Controls.Add(this.label1); this.panel2.Controls.Add(this.dtp1); this.panel2.Controls.Add(this.chkdjsj); this.panel2.Controls.Add(this.butref); this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; this.panel2.Location = new System.Drawing.Point(0, 0); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(832, 64); this.panel2.TabIndex = 3; // // cmbck // this.cmbck.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbck.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.cmbck.Location = new System.Drawing.Point(72, 21); this.cmbck.Name = "cmbck"; this.cmbck.Size = new System.Drawing.Size(112, 20); this.cmbck.TabIndex = 28; this.cmbck.SelectedIndexChanged += new System.EventHandler(this.cmbck_SelectedIndexChanged); // // label3 // this.label3.Location = new System.Drawing.Point(17, 24); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(56, 16); this.label3.TabIndex = 29; this.label3.Text = "仓库名称"; // // dtp2 // this.dtp2.Enabled = false; this.dtp2.Location = new System.Drawing.Point(419, 22); this.dtp2.Name = "dtp2"; this.dtp2.Size = new System.Drawing.Size(110, 21); this.dtp2.TabIndex = 11; // // label1 // this.label1.Location = new System.Drawing.Point(395, 27); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(24, 17); this.label1.TabIndex = 10; this.label1.Text = "到"; // // dtp1 // this.dtp1.Enabled = false; this.dtp1.Location = new System.Drawing.Point(283, 22); this.dtp1.Name = "dtp1"; this.dtp1.Size = new System.Drawing.Size(110, 21); this.dtp1.TabIndex = 9; // // chkdjsj // this.chkdjsj.Location = new System.Drawing.Point(211, 21); this.chkdjsj.Name = "chkdjsj"; this.chkdjsj.Size = new System.Drawing.Size(80, 22); this.chkdjsj.TabIndex = 8; this.chkdjsj.Text = "登记时间"; this.chkdjsj.CheckedChanged += new System.EventHandler(this.chkshdh_CheckedChanged); // // butref // this.butref.Location = new System.Drawing.Point(557, 20); this.butref.Name = "butref"; this.butref.Size = new System.Drawing.Size(88, 24); this.butref.TabIndex = 4; this.butref.Text = "刷新(&R)"; this.butref.Click += new System.EventHandler(this.butref_Click); // // Frmtitle // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(832, 485); this.Controls.Add(this.panel1); this.Name = "Frmtitle"; this.Text = "药品盘点单"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.Frmtitle_Load); this.panel1.ResumeLayout(false); this.panel5.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.myDataGrid1)).EndInit(); this.panel4.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit(); this.panel3.ResumeLayout(false); this.panel2.ResumeLayout(false); this.ResumeLayout(false); }
private void InitValues(List <DrillParameter> parameters) { this.tbReportFile.Text = _DrillReport; // Initialize the DataGrid columns dgtbName = new DataGridTextBoxColumn(); dgtbValue = new DataGridTextBoxColumn(); dgtbOmit = new DataGridTextBoxColumn(); this.dgTableStyle.GridColumnStyles.AddRange(new DataGridColumnStyle[] { this.dgtbName, this.dgtbValue, this.dgtbOmit }); // // dgtbFE // dgtbName.HeaderText = "Parameter Name"; dgtbName.MappingName = "ParameterName"; dgtbName.Width = 75; // // dgtbValue // this.dgtbValue.HeaderText = "Value"; this.dgtbValue.MappingName = "Value"; this.dgtbValue.Width = 75; // // dgtbOmit // this.dgtbOmit.HeaderText = "Omit"; this.dgtbOmit.MappingName = "Omit"; this.dgtbOmit.Width = 75; // Initialize the DataTable _DataTable = new DataTable(); _DataTable.Columns.Add(new DataColumn("ParameterName", typeof(string))); _DataTable.Columns.Add(new DataColumn("Value", typeof(string))); _DataTable.Columns.Add(new DataColumn("Omit", typeof(string))); string[] rowValues = new string[3]; if (parameters != null) { foreach (DrillParameter dp in parameters) { rowValues[0] = dp.ParameterName; rowValues[1] = dp.ParameterValue; rowValues[2] = dp.ParameterOmit; _DataTable.Rows.Add(rowValues); } } // Don't allow new rows; do this by creating a DataView over the DataTable // DataView dv = new DataView(_DataTable); // this has bad side effects // dv.AllowNew = false; this.dgParms.DataSource = _DataTable; DataGridTableStyle ts = dgParms.TableStyles[0]; ts.GridColumnStyles[0].Width = 140; ts.GridColumnStyles[0].ReadOnly = true; ts.GridColumnStyles[1].Width = 140; ts.GridColumnStyles[2].Width = 70; }
private void InitValues() { // Initialize the DataGrid columns DataGridTextBoxColumn dgtbName = new DataGridTextBoxColumn(); DataGridTextBoxColumn dgtbQueryName = new DataGridTextBoxColumn(); DataGridTextBoxColumn dgtbValue = new DataGridTextBoxColumn(); DataGridTextBoxColumn dgtbTypeName = new DataGridTextBoxColumn(); this.dataGridTableStyle1.GridColumnStyles.AddRange(new DataGridColumnStyle[] { dgtbName, dgtbQueryName, dgtbValue, dgtbTypeName }); // dgtbName dgtbName.Format = ""; dgtbName.FormatInfo = null; dgtbName.HeaderText = "Name"; dgtbName.MappingName = "Name"; dgtbName.Width = 75; // dgtbQueryName dgtbQueryName.Format = ""; dgtbQueryName.FormatInfo = null; dgtbQueryName.HeaderText = "Query Column Name"; dgtbQueryName.MappingName = "QueryName"; dgtbQueryName.Width = 80; // dgtbValue // dgtbValue.Format = ""; dgtbValue.FormatInfo = null; dgtbValue.HeaderText = "Value"; dgtbValue.MappingName = "Value"; dgtbValue.Width = 175; // dgtbTypeName dgtbTypeName.Format = ""; dgtbTypeName.FormatInfo = null; dgtbTypeName.HeaderText = "TypeName"; dgtbTypeName.MappingName = "TypeName"; dgtbTypeName.Width = 150; // cbDataSource cbDataSource.Items.AddRange(_Draw.DataSourceNames); // // Obtain the existing DataSet info // XmlNode dNode = this._dsNode; XmlAttribute nAttr = dNode.Attributes["Name"]; _dsv = new DataSetValues(nAttr == null? "": nAttr.Value); _dsv.Node = dNode; XmlNode ctNode = DesignXmlDraw.FindNextInHierarchy(dNode, "Query", "CommandText"); _dsv.CommandText = ctNode == null? "": ctNode.InnerText; XmlNode datasource = DesignXmlDraw.FindNextInHierarchy(dNode, "Query", "DataSourceName"); _dsv.DataSourceName = datasource == null? "": datasource.InnerText; XmlNode timeout = DesignXmlDraw.FindNextInHierarchy(dNode, "Query", "Timeout"); try { _dsv.Timeout = timeout == null? 0: Convert.ToInt32(timeout.InnerText); } catch // we don't stop just because timeout isn't convertable { _dsv.Timeout = 0; } // Get QueryParameters; they are loaded here but used by the QueryParametersCtl _dsv.QueryParameters = new DataTable(); _dsv.QueryParameters.Columns.Add(new DataColumn("Name", typeof(string))); _dsv.QueryParameters.Columns.Add(new DataColumn("Value", typeof(string))); XmlNode qpNode = DesignXmlDraw.FindNextInHierarchy(dNode, "Query", "QueryParameters"); if (qpNode != null) { string[] rowValues = new string[2]; foreach (XmlNode qNode in qpNode.ChildNodes) { if (qNode.Name != "QueryParameter") { continue; } XmlAttribute xAttr = qNode.Attributes["Name"]; if (xAttr == null) { continue; } rowValues[0] = xAttr.Value; rowValues[1] = _Draw.GetElementValue(qNode, "Value", ""); _dsv.QueryParameters.Rows.Add(rowValues); } } // Get Fields _dsv.Fields = new DataTable(); _dsv.Fields.Columns.Add(new DataColumn("Name", typeof(string))); _dsv.Fields.Columns.Add(new DataColumn("QueryName", typeof(string))); _dsv.Fields.Columns.Add(new DataColumn("Value", typeof(string))); _dsv.Fields.Columns.Add(new DataColumn("TypeName", typeof(string))); XmlNode fsNode = _Draw.GetNamedChildNode(dNode, "Fields"); if (fsNode != null) { string[] rowValues = new string[4]; foreach (XmlNode fNode in fsNode.ChildNodes) { if (fNode.Name != "Field") { continue; } XmlAttribute xAttr = fNode.Attributes["Name"]; if (xAttr == null) { continue; } rowValues[0] = xAttr.Value; rowValues[1] = _Draw.GetElementValue(fNode, "DataField", ""); rowValues[2] = _Draw.GetElementValue(fNode, "Value", ""); string typename = null; typename = _Draw.GetElementValue(fNode, "TypeName", null); if (typename == null) { typename = _Draw.GetElementValue(fNode, "rd:TypeName", null); if (typename != null) { _UseTypenameQualified = true; // we got it qualified so we'll generate qualified } } rowValues[3] = typename == null?"":typename; _dsv.Fields.Rows.Add(rowValues); } } this.tbDSName.Text = _dsv.Name; this.tbSQL.Text = _dsv.CommandText; this.cbDataSource.Text = _dsv.DataSourceName; dgFields.DataSource = _dsv.Fields; }
void Form1_Load (object sender, EventArgs e) { /* Generate sample data Two columns: Decimal - uses CRTextBoxColumn for column style. Integer - uses standard DataGridTextBoxColumn for column style. */ DataTable dt = new DataTable (); dt.TableName = "TestTable"; dt.Columns.Add ("Amount", typeof(Decimal)); dt.Columns.Add ("ColB", typeof (Int32)); ds.Tables.Add(dt); dt.Rows.Add(new object[] {2, 4}); dt.Rows.Add(new object[] {-3.45, 5}); dt.Rows.Add(new object[] {4.25, 6}); dt.Rows.Add(new object[] {-1.33, 7}); /* * Create DataGridTableStyle and DataGridColumnStyle objects * and add them the the DataGrid. */ DataGridTableStyle ts = new DataGridTableStyle (); DataGridColumnStyle cs; /* Add the custom column style. */ cs = new CRTextBoxColumn(); cs.Width = 120; cs.MappingName = "Amount"; /* Map to decimal column. */ cs.HeaderText = "Charge/Payment"; ts.GridColumnStyles.Add(cs); /* Add the standard column style. */ cs = new DataGridTextBoxColumn(); cs.Width = 100; cs.MappingName = "ColB"; /* Map to integer column. */ cs.HeaderText = "Integer Col"; ts.GridColumnStyles.Add(cs); ts.MappingName = "TestTable"; /* Map table style to TestTable. */ dataGrid1.TableStyles.Add(ts); dataGrid1.DataSource = ds; dataGrid1.DataMember = "TestTable"; }
private void frmFcProfExp1_Load(object sender, EventArgs e) { string selectConnectionString = "data source=" + Variables.gServer + ";user id=teleprinter;password=tele;initial catalog=Colector;persist security info=True;packet size=4096"; string selectCommandText = "select * from " + Variables.gTermi + "TmpOVCli order by NomAlmacen,NroOV"; this.Adaptador = new SqlDataAdapter(selectCommandText, selectConnectionString); this.DS.Clear(); this.Adaptador.Fill(this.DS, Variables.gTermi + "TmpOVCli"); this.dgTmpOVCli.DataSource = this.DS.Tables[Variables.gTermi + "TmpOVCli"]; DataGridTableStyle table = new DataGridTableStyle(); table.MappingName = Variables.gTermi + "TmpOVCli"; DataGridTextBoxColumn column = new DataGridTextBoxColumn(); DataGridTextBoxColumn column16 = column; column16.HeaderText = "Nro. OV"; column16.MappingName = "NroOV"; column16.Alignment = HorizontalAlignment.Center; column16.Width = 100; column16 = null; table.GridColumnStyles.Add(column); column = new DataGridTextBoxColumn(); DataGridTextBoxColumn column15 = column; column15.HeaderText = ""; column15.MappingName = "Almacen"; column15.Width = 0; column15 = null; table.GridColumnStyles.Add(column); column = new DataGridTextBoxColumn(); DataGridTextBoxColumn column14 = column; column14.HeaderText = "Almac\x00e9n"; column14.MappingName = "NomAlmacen"; column14.Width = 250; column14 = null; table.GridColumnStyles.Add(column); column = new DataGridTextBoxColumn(); DataGridTextBoxColumn column13 = column; column13.HeaderText = ""; column13.MappingName = "Moneda"; column13.Width = 0; column13 = null; table.GridColumnStyles.Add(column); column = new DataGridTextBoxColumn(); DataGridTextBoxColumn column12 = column; column12.HeaderText = ""; column12.MappingName = "CondPago"; column12.Width = 0; column12 = null; table.GridColumnStyles.Add(column); column = new DataGridTextBoxColumn(); DataGridTextBoxColumn column11 = column; column11.HeaderText = ""; column11.MappingName = "CondEnt"; column11.Width = 0; column11 = null; table.GridColumnStyles.Add(column); this.dgTmpOVCli.TableStyles.Add(table); this.dgTmpOVCli.Refresh(); selectCommandText = "select * from " + Variables.gTermi + "TmpOVFcProExp order by NomAlmacen,NroOV"; this.Adap2 = new SqlDataAdapter(selectCommandText, selectConnectionString); this.Adap2.Fill(this.DS, Variables.gTermi + "TmpOVFcProExp"); this.dgTmpOVFcProExp.DataSource = this.DS.Tables[Variables.gTermi + "TmpOVFcProExp"]; this.dgTmpOVFcProExp.Refresh(); DataGridTableStyle style2 = new DataGridTableStyle(); style2.MappingName = Variables.gTermi + "TmpOVFcProExp"; DataGridTextBoxColumn column2 = new DataGridTextBoxColumn(); DataGridTextBoxColumn column10 = column2; column10.HeaderText = "Nro. OV"; column10.MappingName = "NroOV"; column10.Alignment = HorizontalAlignment.Center; column10.Width = 100; column10 = null; style2.GridColumnStyles.Add(column2); column2 = new DataGridTextBoxColumn(); DataGridTextBoxColumn column9 = column2; column9.HeaderText = ""; column9.MappingName = "Almacen"; column9.Width = 0; column9 = null; style2.GridColumnStyles.Add(column2); column2 = new DataGridTextBoxColumn(); DataGridTextBoxColumn column8 = column2; column8.HeaderText = "Almac\x00e9n"; column8.MappingName = "NomAlmacen"; column8.Width = 250; column8 = null; style2.GridColumnStyles.Add(column2); column2 = new DataGridTextBoxColumn(); DataGridTextBoxColumn column7 = column2; column7.HeaderText = "Flete"; column7.MappingName = "Flete"; column7.Format = "######0.00"; column7.Alignment = HorizontalAlignment.Right; column7.Width = 80; column7 = null; style2.GridColumnStyles.Add(column2); column2 = new DataGridTextBoxColumn(); DataGridTextBoxColumn column6 = column2; column6.HeaderText = "Moneda"; column6.MappingName = "Moneda"; column6.Alignment = HorizontalAlignment.Center; column6.Width = 80; column6 = null; style2.GridColumnStyles.Add(column2); column2 = new DataGridTextBoxColumn(); DataGridTextBoxColumn column5 = column2; column5.HeaderText = "Tipo Flete"; column5.MappingName = "Tipo"; column5.Alignment = HorizontalAlignment.Center; column5.Width = 0x4b; column5 = null; style2.GridColumnStyles.Add(column2); column2 = new DataGridTextBoxColumn(); DataGridTextBoxColumn column4 = column2; column4.HeaderText = ""; column4.MappingName = "CondPago"; column4.Width = 0; column4 = null; style2.GridColumnStyles.Add(column2); column2 = new DataGridTextBoxColumn(); DataGridTextBoxColumn column3 = column2; column3.HeaderText = ""; column3.MappingName = "CondEnt"; column3.Width = 0; column3 = null; style2.GridColumnStyles.Add(column2); this.dgTmpOVFcProExp.TableStyles.Add(style2); this.dgTmpOVFcProExp.Refresh(); this.txtCliente.Text = Variables.gNomCli; }
private void btnView_Click(object sender, EventArgs e) { string strclbh = this.txtCLBH.Text.Trim(); if (strclbh.Length == 0) { MessageBox.Show("请扫入材料编号再查询!"); return; } string strsql = "exec 查询材料库存信息 '" + strclbh + "' "; DataTable dtQuery = new DataTable(); dtQuery = DataClass.GetTable(strsql); dtQuery.TableName = "dtQuery"; if (dtQuery.Rows.Count == 0) { this.txtCLBH.SelectAll(); this.txtCLBH.Focus(); return; } this.dataGrid1.DataSource = null; //this.dataGrid1.TableStyles.RemoveAt(0); this.txtQty.Text = dtQuery.Rows[0]["总库存"].ToString(); this.txtEDPQty.Text = dtQuery.Rows[0]["EDP库存"].ToString(); this.txtCheckQty.Text = dtQuery.Rows[0]["待检数量"].ToString(); this.txtOKAQty.Text = dtQuery.Rows[0]["原材料A"].ToString(); this.txtOKBQty.Text = dtQuery.Rows[0]["原材料B"].ToString(); this.txtnoSend.Text = dtQuery.Rows[0]["未导数量"].ToString(); DataGridTableStyle myStyle = new DataGridTableStyle(); this.dataGrid1.TableStyles.Add(myStyle); myStyle.MappingName = dtQuery.TableName; DataGridTextBoxColumn myCol1 = new DataGridTextBoxColumn(); DataGridTextBoxColumn myCol2 = new DataGridTextBoxColumn(); DataGridTextBoxColumn myCol3 = new DataGridTextBoxColumn(); myStyle.GridColumnStyles.Add(myCol1); myCol1.HeaderText = "仓位号"; myCol1.MappingName = "仓位号"; myCol1.Width = 100; myStyle.GridColumnStyles.Add(myCol2); myCol2.HeaderText = "数量"; myCol2.MappingName = "数量"; myCol2.Width = 60; myStyle.GridColumnStyles.Add(myCol3); myCol3.HeaderText = "件数"; myCol3.MappingName = "件数"; myCol3.Width = 30; this.dataGrid1.DataSource = dtQuery; this.txtCLBH.SelectAll(); this.txtCLBH.Focus(); }
}// CRemotingProp3 //------------------------------------------------- // InsertPropSheetPageControls // // This function will create all the winforms controls // and parent them to the passed-in Window Handle. // // Note: For some winforms controls, such as radio buttons // and datagrids, we need to create a container, parent the // container to our window handle, and then parent our // winform controls to the container. //------------------------------------------------- internal override int InsertPropSheetPageControls() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CRemotingProp3)); this.m_cbChannel = new System.Windows.Forms.ComboBox(); this.m_lblGenHelp = new System.Windows.Forms.Label(); this.m_lblHelp = new System.Windows.Forms.Label(); this.m_lblChooseChannel = new System.Windows.Forms.Label(); this.m_dg = new MyDataGrid(); this.m_cbChannel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_cbChannel.DropDownWidth = 152; this.m_cbChannel.Location = ((System.Drawing.Point)(resources.GetObject("m_cbChannel.Location"))); this.m_cbChannel.Size = ((System.Drawing.Size)(resources.GetObject("m_cbChannel.Size"))); this.m_cbChannel.TabIndex = ((int)(resources.GetObject("m_cbChannel.TabIndex"))); m_cbChannel.Name = "Channels"; this.m_lblGenHelp.Location = ((System.Drawing.Point)(resources.GetObject("m_lblGenHelp.Location"))); this.m_lblGenHelp.Size = ((System.Drawing.Size)(resources.GetObject("m_lblGenHelp.Size"))); this.m_lblGenHelp.TabIndex = ((int)(resources.GetObject("m_lblGenHelp.TabIndex"))); this.m_lblGenHelp.Text = resources.GetString("m_lblGenHelp.Text"); m_lblGenHelp.Name = "GeneralHelp"; this.m_lblHelp.Location = ((System.Drawing.Point)(resources.GetObject("m_lblHelp.Location"))); this.m_lblHelp.Size = ((System.Drawing.Size)(resources.GetObject("m_lblHelp.Size"))); this.m_lblHelp.TabIndex = ((int)(resources.GetObject("m_lblHelp.TabIndex"))); this.m_lblHelp.Text = resources.GetString("m_lblHelp.Text"); m_lblHelp.Name = "Help"; this.m_lblChooseChannel.Location = ((System.Drawing.Point)(resources.GetObject("m_lblChooseChannel.Location"))); this.m_lblChooseChannel.Size = ((System.Drawing.Size)(resources.GetObject("m_lblChooseChannel.Size"))); this.m_lblChooseChannel.TabIndex = ((int)(resources.GetObject("m_lblChooseChannel.TabIndex"))); this.m_lblChooseChannel.Text = resources.GetString("m_lblChooseChannel.Text"); m_lblChooseChannel.Name = "ChooseChannel"; this.m_dg.DataMember = ""; this.m_dg.Location = ((System.Drawing.Point)(resources.GetObject("m_dg.Location"))); this.m_dg.Size = ((System.Drawing.Size)(resources.GetObject("m_dg.Size"))); this.m_dg.TabIndex = ((int)(resources.GetObject("m_dg.TabIndex"))); m_dg.Name = "Grid"; m_dg.BackgroundColor = Color.White; PageControls.AddRange(new System.Windows.Forms.Control[] { this.m_dg, this.m_lblHelp, m_lblGenHelp, this.m_lblChooseChannel, this.m_cbChannel }); //---------- Begin Data Table ---------------- m_dt = new DataTable("Attributes"); m_ds = new DataSet(); m_ds.Tables.Add(m_dt); m_dt.DefaultView.AllowNew = false; // Create the "Attribute" Column DataColumn dcAttribute = new DataColumn(); dcAttribute.ColumnName = "Attribute"; dcAttribute.DataType = typeof(String); m_dt.Columns.Add(dcAttribute); // Create the "Value" Column DataColumn dcValue = new DataColumn(); dcValue.ColumnName = "Value"; dcValue.DataType = typeof(String); m_dt.Columns.Add(dcValue); // Now set up any column-specific behavioral stuff.... // like setting column widths, etc. DataGridTableStyle dgtsAct = new DataGridTableStyle(); DataGridTextBoxColumn dgtbcAttribute = new DataGridTextBoxColumn(); DataGridTextBoxColumn dgtbcValue = new DataGridTextBoxColumn(); m_dg.TableStyles.Add(dgtsAct); dgtsAct.MappingName = "Attributes"; dgtsAct.RowHeadersVisible = false; dgtsAct.AllowSorting = false; dgtsAct.ReadOnly = false; // Set up the column info for the Object Type column dgtbcAttribute.MappingName = "Attribute"; dgtbcAttribute.HeaderText = CResourceStore.GetString("CRemotingProp3:AttributeColumn"); dgtbcAttribute.ReadOnly = true; dgtbcAttribute.Width = ScaleWidth(CResourceStore.GetInt("CRemotingProp3:AttributeColumnWidth")); dgtbcAttribute.NullText = ""; dgtsAct.GridColumnStyles.Add(dgtbcAttribute); // Set up the column info for the value column dgtbcValue.MappingName = "Value"; dgtbcValue.HeaderText = CResourceStore.GetString("CRemotingProp3:ValueColumn"); dgtbcValue.ReadOnly = false; dgtbcValue.Width = ScaleWidth(CResourceStore.GetInt("CRemotingProp3:ValueColumnWidth")); dgtbcValue.NullText = ""; dgtbcValue.TextBox.TextChanged += new EventHandler(onChange); dgtsAct.GridColumnStyles.Add(dgtbcValue); m_dg.DataSource = m_dt; //---------- End Data Table ---------------- // Fill in the data PutValuesinPage(); // Do some UI tweaks m_dg.ReadOnly = false; m_dg.CaptionVisible = false; m_dg.ParentRowsVisible = false; // Now finally hook up event handlers m_cbChannel.SelectedIndexChanged += new EventHandler(onChannelChange); m_dg.TheVertScrollBar.VisibleChanged += new EventHandler(onVisibleChange); return(1); }// InsertPropSheetPageControls
private void CarregaCupom() { richTextBox1.ScrollBars = RichTextBoxScrollBars.Vertical; richTextBox1.Refresh(); try { //if(_list.Count() == 0) // _list = SqliteDataAccess.CarregaDadosEstacionamento(); // int idInicial = 1; DataGridTableStyle tableStyle = new DataGridTableStyle(); DataGridTextBoxColumn txtColumn = new DataGridTextBoxColumn(); txtColumn.HeaderText = "Coluna 1"; //txtColumn.Width = 100; tableStyle.GridColumnStyles.Add(txtColumn); //DataGridTextBoxColumn txtColumn2 = new DataGridTextBoxColumn(); //txtColumn2.HeaderText = "Coluna 2"; //txtColumn2.Width = 50; //tableStyle.GridColumnStyles.Add(txtColumn2); DataGrid ordGrid = new DataGrid(); ordGrid.TableStyles.Add(tableStyle); DataTable dTable = new DataTable(); dTable.Columns.Add(new DataColumn("Coluna 1")); //dTable.Columns.Add(new DataColumn("Coluna 2")); DataRow dr = dTable.NewRow(); //dr["Coluna 1"] = "\t\tENTRADA"; dTable.Rows.Add(dr); foreach (RegistrosModel reg in _listCupom) { dr = dTable.NewRow(); dr["Coluna 1"] = "Data Entrada: " + reg.data_entrada + Environment.NewLine + "Data saida: " + reg.data_saida + Environment.NewLine + "Impresso: " + (reg.impresso == 1 ? "Sim" : "Nao") + Environment.NewLine + "Tipo: " + reg.tipo + Environment.NewLine + "Valor: R$ " + reg.total_pagar + ",00" + Environment.NewLine + Environment.NewLine; dTable.Rows.Add(dr); } ordGrid.DataSource = dTable.DefaultView; ordGrid.Refresh(); richTextBox1.Text = ""; float[] tabs = { 30, 60 }; _stringFormat.SetTabStops(0, tabs); for (int i = 0; i < dTable.Rows.Count; i++) { for (int j = 0; j < dTable.Columns.Count; j++) { richTextBox1.Text += "\t" + dTable.Rows[i][j].ToString() + (j == 0 ? "\t" : "\n"); } richTextBox1.Text += "" + Environment.NewLine; } richTextBox1.SelectAll(); richTextBox1.SelectionTabs = new int[] { 30, 60 }; richTextBox1.AcceptsTab = true; richTextBox1.Select(0, 0); } catch (Exception ex) { throw ex; } }
private void CarregaCupom() { try { if (_list.Count() == 0) { _list = SqliteDataAccess.CarregaDadosEstacionamento(); } int idInicial = 1; if (_listCupom.Count() == 0) { _listCupom = SqliteDataAccess.CarregaUltimoCupom(); } else { idInicial = _listCupom[0].id; } DataGridTableStyle tableStyle = new DataGridTableStyle(); DataGridTextBoxColumn txtColumn = new DataGridTextBoxColumn(); txtColumn.HeaderText = "Coluna 1"; txtColumn.Width = 100; tableStyle.GridColumnStyles.Add(txtColumn); DataGridTextBoxColumn txtColumn2 = new DataGridTextBoxColumn(); txtColumn2.HeaderText = "Coluna 2"; txtColumn2.Width = 50; tableStyle.GridColumnStyles.Add(txtColumn2); DataGrid ordGrid = new DataGrid(); ordGrid.TableStyles.Add(tableStyle); DataTable dTable = new DataTable(); dTable.Columns.Add(new DataColumn("Coluna 1")); dTable.Columns.Add(new DataColumn("Coluna 2")); /*DataRow dr = dTable.NewRow(); * dr["Coluna 1"] = ""; * dr["Coluna 2"] = ""; * dTable.Rows.Add(dr);*/ DataRow dr = dTable.NewRow(); dr["Coluna 1"] = "\t\tENTRADA"; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Cupom\t :"; dr["Coluna 2"] = NumeroCupom(idInicial + 1); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Placa\t\t :"; dr["Coluna 2"] = txtPlaca.Text; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Entrada\t :"; dr["Coluna 2"] = DateTime.Now.ToString("dd/MM/yyyy HH:mm"); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Cabine\t :"; dr["Coluna 2"] = "SAORAFAEL"; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Usuario\t :"; dr["Coluna 2"] = "ADMIN"; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Local\t\t :"; dr["Coluna 2"] = "PATIO"; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Tabela\t :"; dr["Coluna 2"] = cmbTipo.SelectedItem.ToString().Substring(0, 6); dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "Seja bem vindo!"; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = ""; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = _list[0].nome; dr["Coluna 2"] = ""; dTable.Rows.Add(dr); dr = dTable.NewRow(); dr["Coluna 1"] = "CNPJ\t :"; dr["Coluna 2"] = _list[0].cnpj; dTable.Rows.Add(dr); ordGrid.DataSource = dTable.DefaultView; ordGrid.Refresh(); richTextBox1.Text = ""; float[] tabs = { 30, 60 }; _stringFormat.SetTabStops(0, tabs); for (int i = 0; i < dTable.Rows.Count; i++) { for (int j = 0; j < dTable.Columns.Count; j++) { richTextBox1.Text += "\t" + dTable.Rows[i][j].ToString() + (j == 0 ? "\t" : "\n"); } } richTextBox1.SelectAll(); richTextBox1.SelectionTabs = new int[] { 30, 60 }; richTextBox1.AcceptsTab = true; richTextBox1.Select(0, 0); } catch (Exception ex) { throw ex; } }
/// <summary> /// Create the on screen representation of the data /// </summary> /// <param name="dg"></param> private void CreateStyles( DataGrid dg ) { // Create a DataGridTableStyle for the customers table DataGridTableStyle style = new DataGridTableStyle ( ) ; // Map this style to the Customers DataTable style.MappingName = "Customers" ; // Setup each alternate row in a different colour style.AlternatingBackColor = System.Drawing.Color.Bisque ; // Add in a couple of columns. First the ID column DataGridTextBoxColumn customerID = new DataGridTextBoxColumn ( ) ; customerID.HeaderText = "Customer ID" ; customerID.MappingName = "CustomerID" ; customerID.Width = 200 ; // Then the Name column DataGridTextBoxColumn name = new DataGridTextBoxColumn ( ) ; name.HeaderText = "Name" ; name.MappingName = "CompanyName" ; name.Width = 300 ; style.GridColumnStyles.AddRange ( new DataGridColumnStyle [] { customerID , name } ) ; dg.TableStyles.Add ( style ) ; }
private void InitValues() { // Initialize the DataGrid columns // dgtbGE = new DGCBColumn(ComboBoxStyle.DropDown); dgtbGE = new DataGridTextBoxColumn(); this.dgTableStyle.GridColumnStyles.AddRange(new DataGridColumnStyle[] { this.dgtbGE }); // // dgtbGE // dgtbGE.HeaderText = "Expression"; dgtbGE.MappingName = "Expression"; dgtbGE.Width = 175; // Get the parent's dataset name // string dataSetName = _Draw.GetDataSetNameValue(_GroupingParent); // // string[] fields = _Draw.GetFields(dataSetName, true); // if (fields != null) // dgtbGE.CB.Items.AddRange(fields); // Initialize the DataTable _DataTable = new DataTable(); _DataTable.Columns.Add(new DataColumn("Expression", typeof(string))); string[] rowValues = new string[1]; XmlNode grouping = _Draw.GetNamedChildNode(_GroupingParent, "Grouping"); // Handle the group expressions XmlNode groupingExs = _Draw.GetNamedChildNode(grouping, "GroupExpressions"); if (groupingExs != null) { foreach (XmlNode gNode in groupingExs.ChildNodes) { if (gNode.NodeType != XmlNodeType.Element || gNode.Name != "GroupExpression") { continue; } rowValues[0] = gNode.InnerText; _DataTable.Rows.Add(rowValues); } } this.dgGroup.DataSource = _DataTable; DataGridTableStyle ts = dgGroup.TableStyles[0]; // ts.PreferredRowHeight = dgtbGE.CB.Height; ts.GridColumnStyles[0].Width = 330; // if (grouping == null) { this.tbName.Text = ""; this.cbParentExpr.Text = ""; this.cbLabelExpr.Text = ""; } else { this.chkPBE.Checked = _Draw.GetElementValue(grouping, "PageBreakAtEnd", "false").ToLower() == "true"; this.chkPBS.Checked = _Draw.GetElementValue(grouping, "PageBreakAtStart", "false").ToLower() == "true"; this.tbName.Text = _Draw.GetElementAttribute(grouping, "Name", ""); this.cbParentExpr.Text = _Draw.GetElementValue(grouping, "Parent", ""); this.cbLabelExpr.Text = _Draw.GetElementValue(grouping, "Label", ""); } if (_GroupingParent.Name == "TableGroup") { XmlNode repeat; repeat = DesignXmlDraw.FindNextInHierarchy(_GroupingParent, "Header", "RepeatOnNewPage"); if (repeat != null) { this.chkRepeatHeader.Checked = repeat.InnerText.ToLower() == "true"; } repeat = DesignXmlDraw.FindNextInHierarchy(_GroupingParent, "Footer", "RepeatOnNewPage"); if (repeat != null) { this.chkRepeatFooter.Checked = repeat.InnerText.ToLower() == "true"; } this.chkGrpHeader.Checked = _Draw.GetNamedChildNode(_GroupingParent, "Header") != null; this.chkGrpFooter.Checked = _Draw.GetNamedChildNode(_GroupingParent, "Footer") != null; } else { this.chkRepeatFooter.Visible = false; this.chkRepeatHeader.Visible = false; this.chkGrpFooter.Visible = false; this.chkGrpHeader.Visible = false; } if (_GroupingParent.Name == "DynamicColumns" || _GroupingParent.Name == "DynamicRows") { this.chkPBE.Visible = this.chkPBS.Visible = false; } else if (_GroupingParent.Name == "DynamicSeries" || _GroupingParent.Name == "DynamicCategories") { this.chkPBE.Visible = this.chkPBS.Visible = false; this.cbParentExpr.Visible = this.lParent.Visible = false; this.cbLabelExpr.Text = _Draw.GetElementValue(_GroupingParent, "Label", ""); } // load label and parent controls with fields string dsn = _Draw.GetDataSetNameValue(_GroupingParent); if (dsn != null) // found it { string[] f = _Draw.GetFields(dsn, true); if (f != null) { this.cbParentExpr.Items.AddRange(f); this.cbLabelExpr.Items.AddRange(f); } } }
private void fmEmplEdit_Load(object sender, System.EventArgs e) { try { sql = "SELECT TOP 1 MPHOTO FROM EmplMain where MCODE = '" + emplMcode + "'"; OleDbDataAdapter sqlDA = new OleDbDataAdapter(sql, con); sqlDA.SelectCommand.CommandTimeout = 120; sqlDA.Fill(sqlDS, "EmplPhoto"); byte[] photo = (Convert.IsDBNull(sqlDS.Tables["EmplPhoto"].Rows[0][0])) ? new byte[0] : (byte[])sqlDS.Tables["EmplPhoto"].Rows[0][0]; if (photo.Length != 0) { MemoryStream ms = new MemoryStream(photo); pbPhoto.Image = new Bitmap(ms); lbPhoto.Hide(); } else { pbPhoto.Image = null; lbPhoto.Show(); } Refill_Grid(); } catch (Exception e1) { MessageBox.Show(e1.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } if (sqlDS == null) { MessageBox.Show("Не удалось загрузить данные о выбранном сотруднике!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); Close(); } else { try { if (dgCurrent.TableStyles["EmplEdit"] == null) { DataGridTableStyle ts = new DataGridTableStyle(); ts.MappingName = "EmplEdit"; ts.AllowSorting = true; ts.AlternatingBackColor = Color.Honeydew; //ID DataGridTextBoxColumn tb0 = new DataGridTextBoxColumn(); tb0.Width = 40; tb0.MappingName = Convert.ToString(sqlDS.Tables["EmplEdit"].Columns["ID"].ColumnName); tb0.HeaderText = "ID"; tb0.ReadOnly = true; //время прихода DataGridTextBoxColumn tb1 = new DataGridTextBoxColumn(); tb1.Width = 120; tb1.MappingName = Convert.ToString(sqlDS.Tables["EmplEdit"].Columns["INDATETIME"].ColumnName); tb1.HeaderText = "Приход"; //время ухода DataGridTextBoxColumn tb2 = new DataGridTextBoxColumn(); tb2.Width = 120; tb2.MappingName = Convert.ToString(sqlDS.Tables["EmplEdit"].Columns["OUTDATETIME"].ColumnName); tb2.HeaderText = "Уход"; //времени на рабочем месте DataGridTextBoxColumn tb3 = new DataGridTextBoxColumn(); tb3.Width = 100; tb3.MappingName = Convert.ToString(sqlDS.Tables["EmplEdit"].Columns["DUR"].ColumnName); tb3.HeaderText = "Отработано"; tb3.ReadOnly = true; ts.GridColumnStyles.Add(tb0); ts.GridColumnStyles.Add(tb1); ts.GridColumnStyles.Add(tb2); ts.GridColumnStyles.Add(tb3); dgCurrent.TableStyles.Add(ts); dgCurrent.ReadOnly = false; } dgCurrent.SetDataBinding(sqlDS, "EmplEdit"); } catch (Exception e2) { MessageBox.Show("Ошибка при инициализации таблицы. " + e2.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } }
void Bind () { DataTable table = new DataTable (); DataColumn columnA = new DataColumn ("A"); table.Columns.Add (columnA); DataColumn columnB = new DataColumn ("B"); table.Columns.Add (columnB); table.Rows.Add (new object [0]); _dataGrid.TableStyles.Clear (); if (_stylesCheck.Checked) { DataGridTableStyle tableStyle = new DataGridTableStyle (); DataGridColumnStyle colStyleB = new DataGridTextBoxColumn (); colStyleB.MappingName = "B"; colStyleB.HeaderText = "B"; tableStyle.GridColumnStyles.Add (colStyleB); DataGridColumnStyle colStyleD = new DataGridTextBoxColumn (); tableStyle.GridColumnStyles.Add (colStyleD); _dataGrid.TableStyles.Add (tableStyle); } _dataGrid.DataSource = table; table.Columns.Add ("C"); }
/// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.butexcel = new System.Windows.Forms.Button(); this.cmbyjks = new System.Windows.Forms.ComboBox(); this.label6 = new System.Windows.Forms.Label(); this.cmbmonth = new System.Windows.Forms.ComboBox(); this.label3 = new System.Windows.Forms.Label(); this.cmbyear = new System.Windows.Forms.ComboBox(); this.rdo2 = new System.Windows.Forms.RadioButton(); this.dtp2 = new System.Windows.Forms.DateTimePicker(); this.label2 = new System.Windows.Forms.Label(); this.dtp1 = new System.Windows.Forms.DateTimePicker(); this.rdo1 = new System.Windows.Forms.RadioButton(); this.butprint = new System.Windows.Forms.Button(); this.butquit = new System.Windows.Forms.Button(); this.butcx = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.myDataGrid1 = new myDataGrid.myDataGrid(); this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle(); this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn15 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn16 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn(); this.商品名 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn17 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn6 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn7 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn12 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn13 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn8 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn9 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn14 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn10 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn11 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn5 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn18 = new System.Windows.Forms.DataGridTextBoxColumn(); this.statusBar1 = new System.Windows.Forms.StatusBar(); this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel(); this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel(); this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel(); this.statusBarPanel4 = new System.Windows.Forms.StatusBarPanel(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.dataGridTextBoxColumn19 = new System.Windows.Forms.DataGridTextBoxColumn(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.myDataGrid1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).BeginInit(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Controls.Add(this.butexcel); this.groupBox1.Controls.Add(this.cmbyjks); this.groupBox1.Controls.Add(this.label6); this.groupBox1.Controls.Add(this.cmbmonth); this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.cmbyear); this.groupBox1.Controls.Add(this.rdo2); this.groupBox1.Controls.Add(this.dtp2); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.dtp1); this.groupBox1.Controls.Add(this.rdo1); this.groupBox1.Controls.Add(this.butprint); this.groupBox1.Controls.Add(this.butquit); this.groupBox1.Controls.Add(this.butcx); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top; this.groupBox1.Location = new System.Drawing.Point(0, 0); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(864, 94); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "查询"; // // butexcel // this.butexcel.Location = new System.Drawing.Point(729, 43); this.butexcel.Name = "butexcel"; this.butexcel.Size = new System.Drawing.Size(59, 32); this.butexcel.TabIndex = 43; this.butexcel.Text = "导出(&E)"; this.butexcel.Click += new System.EventHandler(this.butexcel_Click); // // cmbyjks // this.cmbyjks.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbyjks.Location = new System.Drawing.Point(90, 17); this.cmbyjks.Name = "cmbyjks"; this.cmbyjks.Size = new System.Drawing.Size(176, 20); this.cmbyjks.TabIndex = 41; this.cmbyjks.SelectionChangeCommitted += new System.EventHandler(this.cmbyjks_SelectionChangeCommitted); // // label6 // this.label6.Location = new System.Drawing.Point(26, 22); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(68, 16); this.label6.TabIndex = 40; this.label6.Text = "药剂科室"; // // cmbmonth // this.cmbmonth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbmonth.Items.AddRange(new object[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }); this.cmbmonth.Location = new System.Drawing.Point(506, 51); this.cmbmonth.Name = "cmbmonth"; this.cmbmonth.Size = new System.Drawing.Size(56, 20); this.cmbmonth.TabIndex = 38; this.cmbmonth.SelectedIndexChanged += new System.EventHandler(this.cmbmonth_SelectedIndexChanged); // // label3 // this.label3.ForeColor = System.Drawing.Color.Black; this.label3.Location = new System.Drawing.Point(482, 59); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(32, 16); this.label3.TabIndex = 37; this.label3.Text = "年"; // // cmbyear // this.cmbyear.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbyear.Items.AddRange(new object[] { "2005", "2006", "2007", "2008", "2009", "2010" }); this.cmbyear.Location = new System.Drawing.Point(418, 51); this.cmbyear.Name = "cmbyear"; this.cmbyear.Size = new System.Drawing.Size(64, 20); this.cmbyear.TabIndex = 36; this.cmbyear.SelectedIndexChanged += new System.EventHandler(this.cmbyear_SelectedIndexChanged); // // rdo2 // this.rdo2.Checked = true; this.rdo2.Location = new System.Drawing.Point(338, 51); this.rdo2.Name = "rdo2"; this.rdo2.Size = new System.Drawing.Size(96, 24); this.rdo2.TabIndex = 35; this.rdo2.TabStop = true; this.rdo2.Text = "按月份查询"; this.rdo2.CheckedChanged += new System.EventHandler(this.rdo1_CheckedChanged); // // dtp2 // this.dtp2.Location = new System.Drawing.Point(218, 51); this.dtp2.Name = "dtp2"; this.dtp2.Size = new System.Drawing.Size(112, 21); this.dtp2.TabIndex = 33; // // label2 // this.label2.Location = new System.Drawing.Point(202, 59); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(16, 16); this.label2.TabIndex = 32; this.label2.Text = "到"; // // dtp1 // this.dtp1.Location = new System.Drawing.Point(90, 51); this.dtp1.Name = "dtp1"; this.dtp1.Size = new System.Drawing.Size(110, 21); this.dtp1.TabIndex = 31; // // rdo1 // this.rdo1.Location = new System.Drawing.Point(26, 51); this.rdo1.Name = "rdo1"; this.rdo1.Size = new System.Drawing.Size(96, 24); this.rdo1.TabIndex = 34; this.rdo1.Text = "按日期从"; this.rdo1.CheckedChanged += new System.EventHandler(this.rdo1_CheckedChanged); // // butprint // this.butprint.Location = new System.Drawing.Point(668, 43); this.butprint.Name = "butprint"; this.butprint.Size = new System.Drawing.Size(60, 32); this.butprint.TabIndex = 30; this.butprint.Text = "打印(&P)"; this.butprint.Click += new System.EventHandler(this.butprint_Click); // // butquit // this.butquit.Location = new System.Drawing.Point(790, 43); this.butquit.Name = "butquit"; this.butquit.Size = new System.Drawing.Size(68, 32); this.butquit.TabIndex = 29; this.butquit.Text = "退出(&Q)"; this.butquit.Click += new System.EventHandler(this.butquit_Click); // // butcx // this.butcx.Location = new System.Drawing.Point(599, 43); this.butcx.Name = "butcx"; this.butcx.Size = new System.Drawing.Size(67, 32); this.butcx.TabIndex = 28; this.butcx.Text = "统计(&V)"; this.butcx.Click += new System.EventHandler(this.butcx_Click); // // label1 // this.label1.ForeColor = System.Drawing.Color.Black; this.label1.Location = new System.Drawing.Point(570, 59); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(32, 16); this.label1.TabIndex = 39; this.label1.Text = "月"; // // myDataGrid1 // this.myDataGrid1.BackgroundColor = System.Drawing.Color.White; this.myDataGrid1.CaptionVisible = false; this.myDataGrid1.DataMember = ""; this.myDataGrid1.Dock = System.Windows.Forms.DockStyle.Fill; this.myDataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.myDataGrid1.Location = new System.Drawing.Point(3, 17); this.myDataGrid1.Name = "myDataGrid1"; this.myDataGrid1.Size = new System.Drawing.Size(858, 395); this.myDataGrid1.TabIndex = 0; this.myDataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] { this.dataGridTableStyle1 }); // // dataGridTableStyle1 // this.dataGridTableStyle1.DataGrid = this.myDataGrid1; this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] { this.dataGridTextBoxColumn1, this.dataGridTextBoxColumn19, this.dataGridTextBoxColumn15, this.dataGridTextBoxColumn16, this.dataGridTextBoxColumn2, this.商品名, this.dataGridTextBoxColumn3, this.dataGridTextBoxColumn4, this.dataGridTextBoxColumn17, this.dataGridTextBoxColumn6, this.dataGridTextBoxColumn7, this.dataGridTextBoxColumn12, this.dataGridTextBoxColumn13, this.dataGridTextBoxColumn8, this.dataGridTextBoxColumn9, this.dataGridTextBoxColumn14, this.dataGridTextBoxColumn10, this.dataGridTextBoxColumn11, this.dataGridTextBoxColumn5, this.dataGridTextBoxColumn18 }); this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGridTableStyle1.ReadOnly = true; // // dataGridTextBoxColumn1 // this.dataGridTextBoxColumn1.Format = ""; this.dataGridTextBoxColumn1.FormatInfo = null; this.dataGridTextBoxColumn1.HeaderText = "序号"; this.dataGridTextBoxColumn1.Width = 35; // // dataGridTextBoxColumn15 // this.dataGridTextBoxColumn15.Format = ""; this.dataGridTextBoxColumn15.FormatInfo = null; this.dataGridTextBoxColumn15.HeaderText = "调价文号"; this.dataGridTextBoxColumn15.Width = 60; // // dataGridTextBoxColumn16 // this.dataGridTextBoxColumn16.Format = ""; this.dataGridTextBoxColumn16.FormatInfo = null; this.dataGridTextBoxColumn16.HeaderText = "调价日期"; this.dataGridTextBoxColumn16.Width = 75; // // dataGridTextBoxColumn2 // this.dataGridTextBoxColumn2.Format = ""; this.dataGridTextBoxColumn2.FormatInfo = null; this.dataGridTextBoxColumn2.HeaderText = "品名"; this.dataGridTextBoxColumn2.Width = 120; // // 商品名 // this.商品名.Format = ""; this.商品名.FormatInfo = null; this.商品名.HeaderText = "商品名"; this.商品名.Width = 120; // // dataGridTextBoxColumn3 // this.dataGridTextBoxColumn3.Format = ""; this.dataGridTextBoxColumn3.FormatInfo = null; this.dataGridTextBoxColumn3.HeaderText = "规格"; this.dataGridTextBoxColumn3.Width = 90; // // dataGridTextBoxColumn4 // this.dataGridTextBoxColumn4.Format = ""; this.dataGridTextBoxColumn4.FormatInfo = null; this.dataGridTextBoxColumn4.HeaderText = "厂家"; this.dataGridTextBoxColumn4.Width = 90; // // dataGridTextBoxColumn17 // this.dataGridTextBoxColumn17.Format = ""; this.dataGridTextBoxColumn17.FormatInfo = null; this.dataGridTextBoxColumn17.HeaderText = "批号"; this.dataGridTextBoxColumn17.NullText = ""; this.dataGridTextBoxColumn17.Width = 60; // // dataGridTextBoxColumn6 // this.dataGridTextBoxColumn6.Format = ""; this.dataGridTextBoxColumn6.FormatInfo = null; this.dataGridTextBoxColumn6.HeaderText = "原批发价"; this.dataGridTextBoxColumn6.Width = 0; // // dataGridTextBoxColumn7 // this.dataGridTextBoxColumn7.Format = ""; this.dataGridTextBoxColumn7.FormatInfo = null; this.dataGridTextBoxColumn7.HeaderText = "调批发价"; this.dataGridTextBoxColumn7.Width = 0; // // dataGridTextBoxColumn12 // this.dataGridTextBoxColumn12.Format = ""; this.dataGridTextBoxColumn12.FormatInfo = null; this.dataGridTextBoxColumn12.HeaderText = "原零售价"; this.dataGridTextBoxColumn12.Width = 60; // // dataGridTextBoxColumn13 // this.dataGridTextBoxColumn13.Format = ""; this.dataGridTextBoxColumn13.FormatInfo = null; this.dataGridTextBoxColumn13.HeaderText = "调零售价"; this.dataGridTextBoxColumn13.Width = 60; // // dataGridTextBoxColumn8 // this.dataGridTextBoxColumn8.Format = ""; this.dataGridTextBoxColumn8.FormatInfo = null; this.dataGridTextBoxColumn8.HeaderText = "调价数量"; this.dataGridTextBoxColumn8.Width = 60; // // dataGridTextBoxColumn9 // this.dataGridTextBoxColumn9.Format = ""; this.dataGridTextBoxColumn9.FormatInfo = null; this.dataGridTextBoxColumn9.HeaderText = "单位"; this.dataGridTextBoxColumn9.Width = 40; // // dataGridTextBoxColumn14 // this.dataGridTextBoxColumn14.Format = ""; this.dataGridTextBoxColumn14.FormatInfo = null; this.dataGridTextBoxColumn14.HeaderText = "单位差价"; this.dataGridTextBoxColumn14.Width = 60; // // dataGridTextBoxColumn10 // this.dataGridTextBoxColumn10.Format = ""; this.dataGridTextBoxColumn10.FormatInfo = null; this.dataGridTextBoxColumn10.HeaderText = "调批发金额"; this.dataGridTextBoxColumn10.Width = 0; // // dataGridTextBoxColumn11 // this.dataGridTextBoxColumn11.Format = ""; this.dataGridTextBoxColumn11.FormatInfo = null; this.dataGridTextBoxColumn11.HeaderText = "调零售金额"; this.dataGridTextBoxColumn11.Width = 75; // // dataGridTextBoxColumn5 // this.dataGridTextBoxColumn5.Format = ""; this.dataGridTextBoxColumn5.FormatInfo = null; this.dataGridTextBoxColumn5.HeaderText = "货号"; this.dataGridTextBoxColumn5.Width = 60; // // dataGridTextBoxColumn18 // this.dataGridTextBoxColumn18.Format = ""; this.dataGridTextBoxColumn18.FormatInfo = null; this.dataGridTextBoxColumn18.HeaderText = "操作员"; this.dataGridTextBoxColumn18.Width = 75; // // statusBar1 // this.statusBar1.Location = new System.Drawing.Point(0, 509); this.statusBar1.Name = "statusBar1"; this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { this.statusBarPanel1, this.statusBarPanel2, this.statusBarPanel3, this.statusBarPanel4 }); this.statusBar1.ShowPanels = true; this.statusBar1.Size = new System.Drawing.Size(864, 24); this.statusBar1.TabIndex = 1; this.statusBar1.Text = "statusBar1"; // // statusBarPanel1 // this.statusBarPanel1.Name = "statusBarPanel1"; this.statusBarPanel1.Width = 150; // // statusBarPanel2 // this.statusBarPanel2.Name = "statusBarPanel2"; this.statusBarPanel2.Width = 150; // // statusBarPanel3 // this.statusBarPanel3.Name = "statusBarPanel3"; this.statusBarPanel3.Width = 150; // // statusBarPanel4 // this.statusBarPanel4.Name = "statusBarPanel4"; this.statusBarPanel4.Width = 1000; // // groupBox2 // this.groupBox2.Controls.Add(this.myDataGrid1); this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox2.Location = new System.Drawing.Point(0, 94); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(864, 415); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; this.groupBox2.Text = "库存情况"; // // dataGridTextBoxColumn19 // this.dataGridTextBoxColumn19.Format = ""; this.dataGridTextBoxColumn19.FormatInfo = null; this.dataGridTextBoxColumn19.HeaderText = "仓库名称"; this.dataGridTextBoxColumn19.MappingName = "仓库名称"; this.dataGridTextBoxColumn19.NullText = ""; this.dataGridTextBoxColumn19.Width = 75; // // Frmtjmx // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(864, 533); this.Controls.Add(this.groupBox2); this.Controls.Add(this.statusBar1); this.Controls.Add(this.groupBox1); this.Name = "Frmtjmx"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "调价查询"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.Frmkccx_Load); this.groupBox1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.myDataGrid1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).EndInit(); this.groupBox2.ResumeLayout(false); this.ResumeLayout(false); }
/******************************************************************************** * This code is an automatically generated application code. * Note:Do not modify the contents of this method with the code editor. * The purpose of this method is to instantiate all the User Interface components * like Button, Data Grid, Labels etc., set their formatting Properties * and display these components in 'ViewProducts' form. *********************************************************************************/ #region Windows Form Designer generated code private void InitializeComponent() { this.closeBtn = new System.Windows.Forms.Button(); this.headerLbl = new System.Windows.Forms.Label(); this.productsDataGrid = new System.Windows.Forms.DataGrid(); this.productsDataGridTableStyle = new System.Windows.Forms.DataGridTableStyle(); this.Product_ID = new System.Windows.Forms.DataGridTextBoxColumn(); this.Product_Name = new System.Windows.Forms.DataGridTextBoxColumn(); this.Product_Desc = new System.Windows.Forms.DataGridTextBoxColumn(); this.Category = new System.Windows.Forms.DataGridTextBoxColumn(); this.Price = new System.Windows.Forms.DataGridTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.productsDataGrid)).BeginInit(); this.SuspendLayout(); // // closeBtn // this.closeBtn.BackColor = System.Drawing.SystemColors.Control; this.closeBtn.Font = new System.Drawing.Font("Verdana", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.closeBtn.ForeColor = System.Drawing.Color.Black; this.closeBtn.Location = new System.Drawing.Point(264, 320); this.closeBtn.Name = "closeBtn"; this.closeBtn.Size = new System.Drawing.Size(64, 24); this.closeBtn.TabIndex = 1; this.closeBtn.Text = "Close"; this.closeBtn.Click += new System.EventHandler(this.closeBtn_Click); // // headerLbl // this.headerLbl.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.headerLbl.Font = new System.Drawing.Font("Verdana", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.headerLbl.ForeColor = System.Drawing.SystemColors.ControlText; this.headerLbl.Location = new System.Drawing.Point(168, 16); this.headerLbl.Name = "headerLbl"; this.headerLbl.Size = new System.Drawing.Size(280, 24); this.headerLbl.TabIndex = 2; this.headerLbl.Text = "Favorite Stores"; this.headerLbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // productsDataGrid // this.productsDataGrid.CaptionFont = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.productsDataGrid.CaptionForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.productsDataGrid.CaptionText = "List of Products"; this.productsDataGrid.DataMember = ""; this.productsDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.productsDataGrid.Location = new System.Drawing.Point(40, 64); this.productsDataGrid.Name = "productsDataGrid"; this.productsDataGrid.ReadOnly = true; this.productsDataGrid.Size = new System.Drawing.Size(528, 240); this.productsDataGrid.TabIndex = 3; this.productsDataGrid.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] { this.productsDataGridTableStyle }); // // productsDataGridTableStyle // this.productsDataGridTableStyle.DataGrid = this.productsDataGrid; this.productsDataGridTableStyle.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] { this.Product_ID, this.Product_Name, this.Product_Desc, this.Category, this.Price }); this.productsDataGridTableStyle.HeaderFont = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.productsDataGridTableStyle.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.productsDataGridTableStyle.MappingName = "Products"; this.productsDataGridTableStyle.ReadOnly = true; // // Product_ID // this.Product_ID.Format = ""; this.Product_ID.FormatInfo = null; this.Product_ID.HeaderText = "ID"; this.Product_ID.MappingName = "Product_ID"; this.Product_ID.Width = 50; // // Product_Name // this.Product_Name.Format = ""; this.Product_Name.FormatInfo = null; this.Product_Name.HeaderText = "Name"; this.Product_Name.MappingName = "Product_Name"; this.Product_Name.Width = 120; // // Product_Desc // this.Product_Desc.Format = ""; this.Product_Desc.FormatInfo = null; this.Product_Desc.HeaderText = "Description"; this.Product_Desc.MappingName = "Product_Desc"; this.Product_Desc.Width = 180; // // Category // this.Category.Format = ""; this.Category.FormatInfo = null; this.Category.HeaderText = "Category"; this.Category.MappingName = "Category"; this.Category.Width = 75; // // Price // this.Price.Format = "0.00"; this.Price.FormatInfo = null; this.Price.HeaderText = "Price $"; this.Price.MappingName = "Price"; this.Price.Width = 64; // // ViewProducts // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(608, 365); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.productsDataGrid, this.headerLbl, this.closeBtn }); this.ForeColor = System.Drawing.Color.Black; this.MaximizeBox = false; this.Name = "ViewProducts"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "ViewProducts"; this.TopMost = true; ((System.ComponentModel.ISupportInitialize)(this.productsDataGrid)).EndInit(); this.ResumeLayout(false); }
public void LoadData(DataBind dbd) { objRet = dbd; // ds.Tables.Clear(); ds.Tables.Add("Links"); // ds.Tables[0].Columns.Add(); ds.Tables[0].Columns.Add(); // ds.Tables[0].Columns[0].Caption = "Fields to be Updated"; ds.Tables[0].Columns[0].ColumnName = "Destination"; ds.Tables[0].Columns[0].DataType = typeof(string); ds.Tables[0].Columns[0].MaxLength = 120; ds.Tables[0].Columns[0].ReadOnly = true; // ds.Tables[0].Columns[1].Caption = "Source Fields"; ds.Tables[0].Columns[1].ColumnName = "Source"; ds.Tables[0].Columns[1].DataType = typeof(string); ds.Tables[0].Columns[1].MaxLength = 120; // ds.Tables[0].Columns[1].ReadOnly = true; // DataGridColumnStyle TextCol; DataGridTableStyle myGridTableStyle = new DataGridTableStyle(); myGridTableStyle.MappingName = "Links"; // TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = ds.Tables[0].Columns[0].ColumnName; TextCol.HeaderText = ds.Tables[0].Columns[0].Caption; TextCol.Width = 160; myGridTableStyle.GridColumnStyles.Add(TextCol); // TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = ds.Tables[0].Columns[1].ColumnName; TextCol.HeaderText = ds.Tables[0].Columns[1].Caption; TextCol.Width = 160; myGridTableStyle.GridColumnStyles.Add(TextCol); // dataGrid1.TableStyles.Clear(); dataGrid1.TableStyles.Add(myGridTableStyle); // dataGrid1.SetDataBinding(ds, "Links"); dataGrid1.ReadOnly = true; // int i; int n = objRet.SourceFieldCount; if (n == 0) { MessageBox.Show("Linked data source not found (SourceFieldCount = 0)"); return; } cbx2 = new System.Windows.Forms.ComboBox(); cbx2.Parent = dataGrid1; cbx2.Visible = false; cbx2.Left = 0; cbx2.SelectedIndexChanged += new EventHandler(cbx2_SelectedIndexChanged); cbx2.Items.Add(""); for (i = 0; i < n; i++) { cbx2.Items.Add(objRet.SourceFields[i]); } object[] vs; for (i = 0; i < n; i++) { vs = new object[2]; vs[0] = objRet.SourceFields[i]; // flds[i].Name; //field to be updated vs[1] = objRet.GetMappedField(objRet.SourceFields[i]); //source field ds.Tables[0].Rows.Add(vs); } }
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; }
/// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.cmbyjks = new System.Windows.Forms.ComboBox(); this.txtxm = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); this.txtfph = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); this.dtprq1 = new System.Windows.Forms.DateTimePicker(); this.dtprq2 = new System.Windows.Forms.DateTimePicker(); this.chkrq = new System.Windows.Forms.CheckBox(); this.label3 = new System.Windows.Forms.Label(); this.butprint = new System.Windows.Forms.Button(); this.butquit = new System.Windows.Forms.Button(); this.butcx = new System.Windows.Forms.Button(); this.chkyjks = new System.Windows.Forms.CheckBox(); this.myDataGrid1 = new myDataGrid.myDataGrid(); this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle(); this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn15 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn16 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn(); this.品名 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn6 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn7 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn12 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn13 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn8 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn9 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn17 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn14 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn11 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn5 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn10 = new System.Windows.Forms.DataGridTextBoxColumn(); this.statusBar1 = new System.Windows.Forms.StatusBar(); this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel(); this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel(); this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.dataGridTextBoxColumn18 = new System.Windows.Forms.DataGridTextBoxColumn(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.myDataGrid1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Controls.Add(this.cmbyjks); this.groupBox1.Controls.Add(this.txtxm); this.groupBox1.Controls.Add(this.label8); this.groupBox1.Controls.Add(this.txtfph); this.groupBox1.Controls.Add(this.label4); this.groupBox1.Controls.Add(this.dtprq1); this.groupBox1.Controls.Add(this.dtprq2); this.groupBox1.Controls.Add(this.chkrq); this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.butprint); this.groupBox1.Controls.Add(this.butquit); this.groupBox1.Controls.Add(this.butcx); this.groupBox1.Controls.Add(this.chkyjks); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top; this.groupBox1.Location = new System.Drawing.Point(0, 0); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(864, 84); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "查询"; // // cmbyjks // this.cmbyjks.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbyjks.Enabled = false; this.cmbyjks.Location = new System.Drawing.Point(94, 20); this.cmbyjks.Name = "cmbyjks"; this.cmbyjks.Size = new System.Drawing.Size(144, 20); this.cmbyjks.TabIndex = 55; // // txtxm // this.txtxm.Enabled = false; this.txtxm.Location = new System.Drawing.Point(402, 19); this.txtxm.Name = "txtxm"; this.txtxm.Size = new System.Drawing.Size(77, 21); this.txtxm.TabIndex = 53; // // label8 // this.label8.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label8.ForeColor = System.Drawing.Color.Black; this.label8.Location = new System.Drawing.Point(338, 22); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(75, 20); this.label8.TabIndex = 52; this.label8.Text = "病人姓名"; // // txtfph // this.txtfph.BackColor = System.Drawing.Color.White; this.txtfph.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.txtfph.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192))))); this.txtfph.Location = new System.Drawing.Point(395, 50); this.txtfph.Name = "txtfph"; this.txtfph.Size = new System.Drawing.Size(84, 21); this.txtfph.TabIndex = 40; this.txtfph.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtmzh_KeyPress); // // label4 // this.label4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.ForeColor = System.Drawing.Color.Black; this.label4.Location = new System.Drawing.Point(345, 53); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(61, 20); this.label4.TabIndex = 50; this.label4.Text = "发票号"; // // dtprq1 // this.dtprq1.Location = new System.Drawing.Point(94, 50); this.dtprq1.Name = "dtprq1"; this.dtprq1.Size = new System.Drawing.Size(106, 21); this.dtprq1.TabIndex = 44; // // dtprq2 // this.dtprq2.Location = new System.Drawing.Point(227, 50); this.dtprq2.Name = "dtprq2"; this.dtprq2.Size = new System.Drawing.Size(109, 21); this.dtprq2.TabIndex = 46; // // chkrq // this.chkrq.Checked = true; this.chkrq.CheckState = System.Windows.Forms.CheckState.Checked; this.chkrq.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.chkrq.ForeColor = System.Drawing.Color.Black; this.chkrq.Location = new System.Drawing.Point(19, 53); this.chkrq.Name = "chkrq"; this.chkrq.Size = new System.Drawing.Size(88, 21); this.chkrq.TabIndex = 47; this.chkrq.Text = "退药日期"; this.chkrq.CheckedChanged += new System.EventHandler(this.chkyjks_CheckedChanged); // // label3 // this.label3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label3.ForeColor = System.Drawing.Color.Black; this.label3.Location = new System.Drawing.Point(207, 55); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(32, 16); this.label3.TabIndex = 45; this.label3.Text = "到"; // // butprint // this.butprint.Location = new System.Drawing.Point(568, 20); this.butprint.Name = "butprint"; this.butprint.Size = new System.Drawing.Size(72, 28); this.butprint.TabIndex = 30; this.butprint.Text = "打印(&P)"; this.butprint.Visible = false; this.butprint.Click += new System.EventHandler(this.butprint_Click); // // butquit // this.butquit.Location = new System.Drawing.Point(640, 20); this.butquit.Name = "butquit"; this.butquit.Size = new System.Drawing.Size(72, 28); this.butquit.TabIndex = 29; this.butquit.Text = "退出(&Q)"; this.butquit.Click += new System.EventHandler(this.butquit_Click); // // butcx // this.butcx.Location = new System.Drawing.Point(495, 20); this.butcx.Name = "butcx"; this.butcx.Size = new System.Drawing.Size(72, 28); this.butcx.TabIndex = 28; this.butcx.Text = "查询(&V)"; this.butcx.Click += new System.EventHandler(this.butcx_Click); // // chkyjks // this.chkyjks.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.chkyjks.ForeColor = System.Drawing.Color.Black; this.chkyjks.Location = new System.Drawing.Point(19, 22); this.chkyjks.Name = "chkyjks"; this.chkyjks.Size = new System.Drawing.Size(88, 21); this.chkyjks.TabIndex = 56; this.chkyjks.Text = "药剂科室"; this.chkyjks.CheckedChanged += new System.EventHandler(this.chkyjks_CheckedChanged); // // myDataGrid1 // this.myDataGrid1.BackgroundColor = System.Drawing.Color.White; this.myDataGrid1.CaptionVisible = false; this.myDataGrid1.DataMember = ""; this.myDataGrid1.Dock = System.Windows.Forms.DockStyle.Fill; this.myDataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.myDataGrid1.Location = new System.Drawing.Point(3, 17); this.myDataGrid1.Name = "myDataGrid1"; this.myDataGrid1.Size = new System.Drawing.Size(858, 405); this.myDataGrid1.TabIndex = 0; this.myDataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] { this.dataGridTableStyle1 }); // // dataGridTableStyle1 // this.dataGridTableStyle1.DataGrid = this.myDataGrid1; this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] { this.dataGridTextBoxColumn1, this.dataGridTextBoxColumn15, this.dataGridTextBoxColumn16, this.dataGridTextBoxColumn2, this.品名, this.dataGridTextBoxColumn3, this.dataGridTextBoxColumn4, this.dataGridTextBoxColumn6, this.dataGridTextBoxColumn7, this.dataGridTextBoxColumn12, this.dataGridTextBoxColumn13, this.dataGridTextBoxColumn8, this.dataGridTextBoxColumn9, this.dataGridTextBoxColumn17, this.dataGridTextBoxColumn14, this.dataGridTextBoxColumn11, this.dataGridTextBoxColumn5, this.dataGridTextBoxColumn10, this.dataGridTextBoxColumn18 }); this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGridTableStyle1.ReadOnly = true; // // dataGridTextBoxColumn1 // this.dataGridTextBoxColumn1.Format = ""; this.dataGridTextBoxColumn1.FormatInfo = null; this.dataGridTextBoxColumn1.HeaderText = "序号"; this.dataGridTextBoxColumn1.Width = 35; // // dataGridTextBoxColumn15 // this.dataGridTextBoxColumn15.Format = ""; this.dataGridTextBoxColumn15.FormatInfo = null; this.dataGridTextBoxColumn15.HeaderText = "发票号"; this.dataGridTextBoxColumn15.Width = 60; // // dataGridTextBoxColumn16 // this.dataGridTextBoxColumn16.Format = ""; this.dataGridTextBoxColumn16.FormatInfo = null; this.dataGridTextBoxColumn16.HeaderText = "姓名"; this.dataGridTextBoxColumn16.Width = 60; // // dataGridTextBoxColumn2 // this.dataGridTextBoxColumn2.Format = ""; this.dataGridTextBoxColumn2.FormatInfo = null; this.dataGridTextBoxColumn2.HeaderText = "门诊号"; this.dataGridTextBoxColumn2.Width = 75; // // 品名 // this.品名.Format = ""; this.品名.FormatInfo = null; this.品名.HeaderText = "品名"; this.品名.Width = 120; // // dataGridTextBoxColumn3 // this.dataGridTextBoxColumn3.Format = ""; this.dataGridTextBoxColumn3.FormatInfo = null; this.dataGridTextBoxColumn3.HeaderText = "规格"; this.dataGridTextBoxColumn3.Width = 90; // // dataGridTextBoxColumn4 // this.dataGridTextBoxColumn4.Format = ""; this.dataGridTextBoxColumn4.FormatInfo = null; this.dataGridTextBoxColumn4.HeaderText = "厂家"; this.dataGridTextBoxColumn4.Width = 90; // // dataGridTextBoxColumn6 // this.dataGridTextBoxColumn6.Format = ""; this.dataGridTextBoxColumn6.FormatInfo = null; this.dataGridTextBoxColumn6.HeaderText = "单价"; this.dataGridTextBoxColumn6.Width = 60; // // dataGridTextBoxColumn7 // this.dataGridTextBoxColumn7.Format = ""; this.dataGridTextBoxColumn7.FormatInfo = null; this.dataGridTextBoxColumn7.HeaderText = "数量"; this.dataGridTextBoxColumn7.Width = 60; // // dataGridTextBoxColumn12 // this.dataGridTextBoxColumn12.Format = ""; this.dataGridTextBoxColumn12.FormatInfo = null; this.dataGridTextBoxColumn12.HeaderText = "单位"; this.dataGridTextBoxColumn12.Width = 40; // // dataGridTextBoxColumn13 // this.dataGridTextBoxColumn13.Format = ""; this.dataGridTextBoxColumn13.FormatInfo = null; this.dataGridTextBoxColumn13.HeaderText = "金额"; this.dataGridTextBoxColumn13.Width = 65; // // dataGridTextBoxColumn8 // this.dataGridTextBoxColumn8.Format = ""; this.dataGridTextBoxColumn8.FormatInfo = null; this.dataGridTextBoxColumn8.HeaderText = "退药日期"; this.dataGridTextBoxColumn8.Width = 120; // // dataGridTextBoxColumn9 // this.dataGridTextBoxColumn9.Format = ""; this.dataGridTextBoxColumn9.FormatInfo = null; this.dataGridTextBoxColumn9.HeaderText = "退药人"; this.dataGridTextBoxColumn9.Width = 60; // // dataGridTextBoxColumn17 // this.dataGridTextBoxColumn17.Format = ""; this.dataGridTextBoxColumn17.FormatInfo = null; this.dataGridTextBoxColumn17.HeaderText = "科室"; this.dataGridTextBoxColumn17.Width = 75; // // dataGridTextBoxColumn14 // this.dataGridTextBoxColumn14.Format = ""; this.dataGridTextBoxColumn14.FormatInfo = null; this.dataGridTextBoxColumn14.HeaderText = "医生"; this.dataGridTextBoxColumn14.Width = 60; // // dataGridTextBoxColumn11 // this.dataGridTextBoxColumn11.Format = ""; this.dataGridTextBoxColumn11.FormatInfo = null; this.dataGridTextBoxColumn11.HeaderText = "YDWBL"; this.dataGridTextBoxColumn11.Width = 0; // // dataGridTextBoxColumn5 // this.dataGridTextBoxColumn5.Format = ""; this.dataGridTextBoxColumn5.FormatInfo = null; this.dataGridTextBoxColumn5.HeaderText = "货号"; this.dataGridTextBoxColumn5.Width = 75; // // dataGridTextBoxColumn10 // this.dataGridTextBoxColumn10.Format = ""; this.dataGridTextBoxColumn10.FormatInfo = null; this.dataGridTextBoxColumn10.HeaderText = "退药药房"; this.dataGridTextBoxColumn10.Width = 75; // // statusBar1 // this.statusBar1.Location = new System.Drawing.Point(0, 509); this.statusBar1.Name = "statusBar1"; this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { this.statusBarPanel1, this.statusBarPanel2, this.statusBarPanel3 }); this.statusBar1.ShowPanels = true; this.statusBar1.Size = new System.Drawing.Size(864, 24); this.statusBar1.TabIndex = 1; this.statusBar1.Text = "statusBar1"; // // statusBarPanel1 // this.statusBarPanel1.Name = "statusBarPanel1"; this.statusBarPanel1.Width = 150; // // statusBarPanel2 // this.statusBarPanel2.Name = "statusBarPanel2"; this.statusBarPanel2.Width = 150; // // statusBarPanel3 // this.statusBarPanel3.Name = "statusBarPanel3"; this.statusBarPanel3.Width = 150; // // groupBox2 // this.groupBox2.Controls.Add(this.myDataGrid1); this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox2.Location = new System.Drawing.Point(0, 84); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(864, 425); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; // // dataGridTextBoxColumn18 // this.dataGridTextBoxColumn18.Format = ""; this.dataGridTextBoxColumn18.FormatInfo = null; this.dataGridTextBoxColumn18.HeaderText = "退药原因"; this.dataGridTextBoxColumn18.Width = 80; // // Frmtyqktj // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(864, 533); this.Controls.Add(this.groupBox2); this.Controls.Add(this.statusBar1); this.Controls.Add(this.groupBox1); this.Name = "Frmtyqktj"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "门诊退药查询"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.Frmkccx_Load); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.myDataGrid1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit(); this.groupBox2.ResumeLayout(false); this.ResumeLayout(false); }
private void AddGridTableStyle(DataGrid v_dg, DataSet v_ds) { try { if (v_dg.TableStyles.Count <= 0) { DataGridTableStyle ts = new DataGridTableStyle(); ts.MappingName = v_ds.Tables[0].TableName; ts.AlternatingBackColor = Color.Beige; ts.BackColor = Color.GhostWhite; ts.ForeColor = Color.MidnightBlue; ts.GridLineColor = Color.RoyalBlue; ts.HeaderBackColor = SystemColors.Control; //Color.MidnightBlue; ts.HeaderForeColor = Color.Black; //.Lavender; ts.SelectionBackColor = Color.Teal; ts.SelectionForeColor = Color.PaleGreen; ts.ReadOnly = false; ts.RowHeaderWidth = 10; DataGridTextBoxColumn TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "cicd10"; TextCol.HeaderText = "ICD10"; TextCol.NullText = ""; TextCol.Width = 50; ts.GridColumnStyles.Add(TextCol); v_dg.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "vviet"; TextCol.HeaderText = "Tên bệnh tật tiếng việt"; TextCol.NullText = ""; TextCol.Width = 400; ts.GridColumnStyles.Add(TextCol); v_dg.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "vanh"; TextCol.HeaderText = "Tên bệnh tật tiếng anh"; TextCol.NullText = ""; TextCol.Width = 295; ts.GridColumnStyles.Add(TextCol); v_dg.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "id_chuong"; TextCol.HeaderText = ""; TextCol.NullText = ""; TextCol.Width = 0; ts.GridColumnStyles.Add(TextCol); v_dg.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "id_nhom"; TextCol.HeaderText = ""; TextCol.NullText = ""; TextCol.Width = 0; ts.GridColumnStyles.Add(TextCol); v_dg.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "chuong"; TextCol.HeaderText = "Chương"; TextCol.Width = 295; TextCol.NullText = ""; ts.GridColumnStyles.Add(TextCol); v_dg.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "nhom"; TextCol.HeaderText = "Nhóm bệnh"; TextCol.Width = 295; TextCol.NullText = ""; ts.GridColumnStyles.Add(TextCol); v_dg.TableStyles.Add(ts); } v_dg.DataSource = v_ds.Tables[0]; } catch { } }
protected override void FormatGridWithBothTableAndColumnStyles() { DataGridLoginUser.BackColor = Color.GhostWhite; DataGridLoginUser.BackgroundColor = Color.Lavender; DataGridLoginUser.BorderStyle = BorderStyle.None; DataGridLoginUser.CaptionBackColor = Color.RoyalBlue; DataGridLoginUser.CaptionFont = new Font("Tahoma", 13.0F, FontStyle.Bold); //10.0 DataGridLoginUser.CaptionForeColor = Color.Bisque; DataGridLoginUser.CaptionText = "服务总线"; // DataGridLoginUser.Font = new Font("Tahoma", 15.0F); //12.0 DataGridLoginUser.ParentRowsBackColor = Color.Lavender; DataGridLoginUser.ParentRowsForeColor = Color.MidnightBlue; DataGridTableStyle grdTableStyle = new DataGridTableStyle(); grdTableStyle.AlternatingBackColor = Color.GhostWhite; grdTableStyle.BackColor = Color.GhostWhite; grdTableStyle.ForeColor = Color.MidnightBlue; grdTableStyle.GridLineColor = Color.RoyalBlue; grdTableStyle.HeaderBackColor = Color.MidnightBlue; grdTableStyle.HeaderFont = new Font("Tahoma", 15.0F, FontStyle.Bold);//12.0 grdTableStyle.HeaderForeColor = Color.Lavender; grdTableStyle.SelectionBackColor = Color.Teal; grdTableStyle.SelectionForeColor = Color.PaleGreen; //grdTableStyle.MappingName = "ArrayList" ; //grdTableStyle.MappingName = ChargeDetailListEntityOBJ.GetType().Name; grdTableStyle.MappingName = MyAsynchMobileAppSocketService.MyManagerLoginMobileUser.MyLoginUserList.GetType().Name;//MyManagerSocketLoginUser.MyLoginUserList.GetType().Name; grdTableStyle.PreferredColumnWidth = 125; grdTableStyle.PreferredRowHeight = 15; grdTableStyle.ReadOnly = true; //---1------------------------------------------------------------------------------------------------- DataGridTextBoxColumn grdColStyle1 = new DataGridTextBoxColumn(); grdColStyle1.HeaderText = "通道编号"; grdColStyle1.MappingName = "LoginID"; grdColStyle1.Alignment = HorizontalAlignment.Center; grdColStyle1.Width = 150; //---2------------------------------------------------------------------------------------------------ DataGridTextBoxColumn grdColStyle2 = new DataGridTextBoxColumn(); grdColStyle2.HeaderText = "套接字"; // grdColStyle2.MappingName = "SocketInfor"; // "GetRemoteEndIP"; grdColStyle2.Alignment = HorizontalAlignment.Center; grdColStyle2.Width = 260; //---3------------------------------------------------------------------ DataGridTextBoxColumn grdColStyle3 = new DataGridTextBoxColumn(); grdColStyle3.HeaderText = "移动端ID"; grdColStyle3.MappingName = "MobileID"; grdColStyle3.Alignment = HorizontalAlignment.Center; grdColStyle3.Width = 230; //---4------------------------------------------------------------------ DataGridTextBoxColumn grdColStyle4 = new DataGridTextBoxColumn(); grdColStyle4.HeaderText = "智能端ID"; grdColStyle4.MappingName = "LockID"; grdColStyle4.Alignment = HorizontalAlignment.Center; grdColStyle4.Width = 230; //---5------------------------------------------------------------------ DataGridTextBoxColumn grdColStyle5 = new DataGridTextBoxColumn(); grdColStyle5.HeaderText = "登录时间"; grdColStyle5.MappingName = "GetLoginTime"; grdColStyle5.Width = 220; grdColStyle5.Alignment = HorizontalAlignment.Center; //---6------------------------------------------------------------------ DataGridTextBoxColumn grdColStyle6 = new DataGridTextBoxColumn(); grdColStyle6.HeaderText = "活动时间"; grdColStyle6.MappingName = "GetKeepTime"; grdColStyle6.Alignment = HorizontalAlignment.Center; grdColStyle6.Width = 220; //------------------------------------------------------------------------------------------------------------------------------ grdTableStyle.GridColumnStyles.AddRange(new DataGridColumnStyle[] { grdColStyle1, grdColStyle2, grdColStyle3, grdColStyle4, grdColStyle5, grdColStyle6 }); DataGridLoginUser.TableStyles.Add(grdTableStyle); }
private void InitializeComponent() { this.imgIcon = new System.Windows.Forms.PictureBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.dgItems = new System.Windows.Forms.DataGrid(); this.dgStyle = new System.Windows.Forms.DataGridTableStyle(); this.TransactionID = new System.Windows.Forms.DataGridTextBoxColumn(); this.TransactionNo = new System.Windows.Forms.DataGridTextBoxColumn(); this.CustomerID = new System.Windows.Forms.DataGridTextBoxColumn(); this.CustomerName = new System.Windows.Forms.DataGridTextBoxColumn(); this.TransactionDate = new System.Windows.Forms.DataGridTextBoxColumn(); this.SubTotal = new System.Windows.Forms.DataGridTextBoxColumn(); this.Discount = new System.Windows.Forms.DataGridTextBoxColumn(); this.AmountPaid = new System.Windows.Forms.DataGridTextBoxColumn(); this.Credit = new System.Windows.Forms.DataGridTextBoxColumn(); this.CreditPaid = new System.Windows.Forms.DataGridTextBoxColumn(); this.Balance = new System.Windows.Forms.DataGridTextBoxColumn(); this.lblHeader1 = new System.Windows.Forms.Label(); this.lblBalanceName = new System.Windows.Forms.Label(); this.lblBalance = new System.Windows.Forms.Label(); this.lblHeader = new System.Windows.Forms.Label(); this.cmdCancel = new System.Windows.Forms.Button(); this.cmdEnter = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.imgIcon)).BeginInit(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgItems)).BeginInit(); this.SuspendLayout(); // // imgIcon // this.imgIcon.BackColor = System.Drawing.Color.Blue; this.imgIcon.Location = new System.Drawing.Point(9, 5); this.imgIcon.Name = "imgIcon"; this.imgIcon.Size = new System.Drawing.Size(49, 49); this.imgIcon.TabIndex = 68; this.imgIcon.TabStop = false; this.imgIcon.Click += new System.EventHandler(this.imgIcon_Click); // // groupBox1 // this.groupBox1.BackColor = System.Drawing.Color.White; this.groupBox1.Controls.Add(this.dgItems); this.groupBox1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.groupBox1.ForeColor = System.Drawing.Color.Blue; this.groupBox1.Location = new System.Drawing.Point(9, 81); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(1009, 391); this.groupBox1.TabIndex = 69; this.groupBox1.TabStop = false; this.groupBox1.Text = "Unpaid Transaction Details"; // // dgItems // this.dgItems.AlternatingBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); this.dgItems.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dgItems.BackColor = System.Drawing.Color.White; this.dgItems.BackgroundColor = System.Drawing.Color.White; this.dgItems.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.dgItems.CaptionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); this.dgItems.CaptionForeColor = System.Drawing.Color.Blue; this.dgItems.CaptionVisible = false; this.dgItems.DataMember = ""; this.dgItems.Enabled = false; this.dgItems.FlatMode = true; this.dgItems.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.dgItems.HeaderBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(81)))), ((int)(((byte)(153))))); this.dgItems.HeaderFont = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.dgItems.HeaderForeColor = System.Drawing.Color.White; this.dgItems.Location = new System.Drawing.Point(8, 24); this.dgItems.Name = "dgItems"; this.dgItems.ReadOnly = true; this.dgItems.RowHeadersVisible = false; this.dgItems.RowHeaderWidth = 5; this.dgItems.SelectionBackColor = System.Drawing.Color.RoyalBlue; this.dgItems.SelectionForeColor = System.Drawing.Color.White; this.dgItems.Size = new System.Drawing.Size(994, 361); this.dgItems.TabIndex = 55; this.dgItems.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] { this.dgStyle }); this.dgItems.TabStop = false; // // dgStyle // this.dgStyle.AlternatingBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); this.dgStyle.DataGrid = this.dgItems; this.dgStyle.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] { this.TransactionID, this.TransactionNo, this.CustomerID, this.CustomerName, this.TransactionDate, this.SubTotal, this.Discount, this.AmountPaid, this.Credit, this.CreditPaid, this.Balance }); this.dgStyle.HeaderBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(81)))), ((int)(((byte)(153))))); this.dgStyle.HeaderFont = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.dgStyle.HeaderForeColor = System.Drawing.Color.White; this.dgStyle.MappingName = "tblForPayment"; this.dgStyle.PreferredColumnWidth = 0; this.dgStyle.ReadOnly = true; this.dgStyle.RowHeadersVisible = false; this.dgStyle.SelectionBackColor = System.Drawing.Color.RoyalBlue; this.dgStyle.SelectionForeColor = System.Drawing.Color.White; // // TransactionID // this.TransactionID.Format = ""; this.TransactionID.FormatInfo = null; this.TransactionID.MappingName = "TransactionID"; this.TransactionID.NullText = ""; this.TransactionID.ReadOnly = true; this.TransactionID.Width = 0; // // TransactionNo // this.TransactionNo.Format = ""; this.TransactionNo.FormatInfo = null; this.TransactionNo.HeaderText = "Trans. No"; this.TransactionNo.MappingName = "TransactionNo"; this.TransactionNo.NullText = ""; this.TransactionNo.ReadOnly = true; this.TransactionNo.Width = 120; // // CustomerID // this.CustomerID.Format = ""; this.CustomerID.FormatInfo = null; this.CustomerID.MappingName = "CustomerID"; this.CustomerID.NullText = ""; this.CustomerID.ReadOnly = true; this.CustomerID.Width = 0; // // CustomerName // this.CustomerName.Format = ""; this.CustomerName.FormatInfo = null; this.CustomerName.MappingName = "CustomerName"; this.CustomerName.NullText = ""; this.CustomerName.ReadOnly = true; this.CustomerName.Width = 0; // // TransactionDate // this.TransactionDate.Format = ""; this.TransactionDate.FormatInfo = null; this.TransactionDate.HeaderText = "Trans. Date"; this.TransactionDate.MappingName = "TransactionDate"; this.TransactionDate.NullText = ""; this.TransactionDate.ReadOnly = true; this.TransactionDate.Width = 90; // // SubTotal // this.SubTotal.Alignment = System.Windows.Forms.HorizontalAlignment.Right; this.SubTotal.Format = ""; this.SubTotal.FormatInfo = null; this.SubTotal.HeaderText = "SubTotal"; this.SubTotal.MappingName = "SubTotal"; this.SubTotal.NullText = ""; this.SubTotal.ReadOnly = true; this.SubTotal.Width = 0; // // Discount // this.Discount.Alignment = System.Windows.Forms.HorizontalAlignment.Right; this.Discount.Format = ""; this.Discount.FormatInfo = null; this.Discount.HeaderText = "Discount"; this.Discount.MappingName = "Discount"; this.Discount.NullText = ""; this.Discount.ReadOnly = true; this.Discount.Width = 0; // // AmountPaid // this.AmountPaid.Alignment = System.Windows.Forms.HorizontalAlignment.Right; this.AmountPaid.Format = ""; this.AmountPaid.FormatInfo = null; this.AmountPaid.HeaderText = "Amnt. Paid"; this.AmountPaid.MappingName = "AmountPaid"; this.AmountPaid.NullText = ""; this.AmountPaid.ReadOnly = true; this.AmountPaid.Width = 0; // // Credit // this.Credit.Alignment = System.Windows.Forms.HorizontalAlignment.Right; this.Credit.Format = ""; this.Credit.FormatInfo = null; this.Credit.HeaderText = "Credit"; this.Credit.MappingName = "Credit"; this.Credit.NullText = ""; this.Credit.ReadOnly = true; this.Credit.Width = 0; // // CreditPaid // this.CreditPaid.Alignment = System.Windows.Forms.HorizontalAlignment.Right; this.CreditPaid.Format = ""; this.CreditPaid.FormatInfo = null; this.CreditPaid.HeaderText = "Amt. Paid"; this.CreditPaid.MappingName = "CreditPaid"; this.CreditPaid.NullText = ""; this.CreditPaid.ReadOnly = true; this.CreditPaid.Width = 0; // // Balance // this.Balance.Alignment = System.Windows.Forms.HorizontalAlignment.Right; this.Balance.Format = ""; this.Balance.FormatInfo = null; this.Balance.HeaderText = "Balance"; this.Balance.MappingName = "Balance"; this.Balance.NullText = ""; this.Balance.ReadOnly = true; this.Balance.Width = 0; // // lblHeader1 // this.lblHeader1.AutoSize = true; this.lblHeader1.BackColor = System.Drawing.Color.Transparent; this.lblHeader1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblHeader1.ForeColor = System.Drawing.Color.White; this.lblHeader1.Location = new System.Drawing.Point(67, 22); this.lblHeader1.Name = "lblHeader1"; this.lblHeader1.Size = new System.Drawing.Size(177, 13); this.lblHeader1.TabIndex = 70; this.lblHeader1.Text = "Current credit transactions of "; // // lblBalanceName // this.lblBalanceName.AutoSize = true; this.lblBalanceName.BackColor = System.Drawing.Color.Transparent; this.lblBalanceName.Font = new System.Drawing.Font("Arial Narrow", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblBalanceName.Location = new System.Drawing.Point(446, 475); this.lblBalanceName.Name = "lblBalanceName"; this.lblBalanceName.Size = new System.Drawing.Size(255, 29); this.lblBalanceName.TabIndex = 86; this.lblBalanceName.Text = "TOTAL CREDIT BALANCE"; // // lblBalance // this.lblBalance.BackColor = System.Drawing.Color.Transparent; this.lblBalance.Font = new System.Drawing.Font("Arial Narrow", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblBalance.ForeColor = System.Drawing.Color.Firebrick; this.lblBalance.Location = new System.Drawing.Point(667, 477); this.lblBalance.Name = "lblBalance"; this.lblBalance.Size = new System.Drawing.Size(351, 25); this.lblBalance.TabIndex = 87; this.lblBalance.Text = "0.00"; this.lblBalance.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // lblHeader // this.lblHeader.AutoSize = true; this.lblHeader.BackColor = System.Drawing.Color.Transparent; this.lblHeader.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblHeader.ForeColor = System.Drawing.Color.Red; this.lblHeader.Location = new System.Drawing.Point(238, 22); this.lblHeader.Name = "lblHeader"; this.lblHeader.Size = new System.Drawing.Size(133, 13); this.lblHeader.TabIndex = 88; this.lblHeader.Text = "RetailPlus Customer ™"; // // cmdCancel // this.cmdCancel.AutoSize = true; this.cmdCancel.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); this.cmdCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.cmdCancel.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cmdCancel.ForeColor = System.Drawing.Color.White; this.cmdCancel.Location = new System.Drawing.Point(765, 618); this.cmdCancel.Name = "cmdCancel"; this.cmdCancel.Size = new System.Drawing.Size(106, 83); this.cmdCancel.TabIndex = 1; this.cmdCancel.Text = "CANCEL"; this.cmdCancel.UseVisualStyleBackColor = true; this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click); // // cmdEnter // this.cmdEnter.AutoSize = true; this.cmdEnter.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); this.cmdEnter.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.cmdEnter.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cmdEnter.ForeColor = System.Drawing.Color.White; this.cmdEnter.Location = new System.Drawing.Point(877, 618); this.cmdEnter.Name = "cmdEnter"; this.cmdEnter.Size = new System.Drawing.Size(106, 83); this.cmdEnter.TabIndex = 0; this.cmdEnter.Text = "ENTER"; this.cmdEnter.UseVisualStyleBackColor = true; this.cmdEnter.Click += new System.EventHandler(this.cmdEnter_Click); // // CreditsWnd // this.AutoScaleBaseSize = new System.Drawing.Size(5, 14); this.BackColor = System.Drawing.Color.White; this.ClientSize = new System.Drawing.Size(1022, 766); this.ControlBox = false; this.Controls.Add(this.cmdCancel); this.Controls.Add(this.cmdEnter); this.Controls.Add(this.lblHeader); this.Controls.Add(this.lblBalanceName); this.Controls.Add(this.lblHeader1); this.Controls.Add(this.lblBalance); this.Controls.Add(this.imgIcon); this.Controls.Add(this.groupBox1); this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.KeyPreview = true; this.Name = "CreditsWnd"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Load += new System.EventHandler(this.CreditsWnd_Load); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CreditsWnd_KeyDown); ((System.ComponentModel.ISupportInitialize)(this.imgIcon)).EndInit(); this.groupBox1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dgItems)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); }
/// <summary> /// Registers the KeyDown EventHandler for DataGridTextBoxColumn; /// </summary> /// <param name="columnStyle"></param> private void EnableSave(DataGridTextBoxColumn columnStyle) { columnStyle.TextBox.KeyDown += new KeyEventHandler(TextBoxKeyDownEventHandler); }
/// <summary> /// 窗体加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CheckStockDetail_Load(object sender, EventArgs e) { DataGridTableStyle dts = new DataGridTableStyle(); DataGridTextBoxColumn dtbc; dtbc = new DataGridTextBoxColumn(); dtbc.HeaderText = "存货编码"; dtbc.MappingName = "cInvCode"; dtbc.Width = 70; dts.GridColumnStyles.Add(dtbc); dtbc = new DataGridTextBoxColumn(); dtbc.HeaderText = "存货名称"; dtbc.MappingName = "cInvName"; dtbc.Width = 90; dts.GridColumnStyles.Add(dtbc); dtbc = new DataGridTextBoxColumn(); dtbc.HeaderText = "规格"; dtbc.MappingName = "cInvStd"; dtbc.Width = 90; dts.GridColumnStyles.Add(dtbc); dtbc = new DataGridTextBoxColumn(); dtbc.HeaderText = "批次"; dtbc.MappingName = "cbatch"; dtbc.Width = 110; dts.GridColumnStyles.Add(dtbc); dtbc = new DataGridTextBoxColumn(); dtbc.HeaderText = "生产日期"; dtbc.MappingName = "dMadeDate"; dtbc.Width = 90; dtbc.Format = "yyyy-MM-dd"; dts.GridColumnStyles.Add(dtbc); dtbc = new DataGridTextBoxColumn(); dtbc.HeaderText = "失效日期"; dtbc.MappingName = "dvdate"; dtbc.Width = 90; dtbc.Format = "yyyy-MM-dd"; dts.GridColumnStyles.Add(dtbc); dtbc = new DataGridTextBoxColumn(); dtbc.HeaderText = "账面数量"; dtbc.MappingName = "iCVQuantity"; dtbc.Format = "F2"; dtbc.Width = 70; dts.GridColumnStyles.Add(dtbc); dtbc = new DataGridTextBoxColumn(); dtbc.HeaderText = "盘点数量"; dtbc.MappingName = "iCVCQuantity"; dtbc.Format = "F2"; dtbc.Width = 70; dts.GridColumnStyles.Add(dtbc); dtbc = new DataGridTextBoxColumn(); dtbc.HeaderText = "盈亏数量"; dtbc.MappingName = "cAlcQuantity"; dtbc.Format = "F2"; dtbc.Width = 70; dts.GridColumnStyles.Add(dtbc); dgView.TableStyles.Add(dts); dgView.RowHeadersVisible = true; dts.MappingName = list.GetType().Name; this.dgView.DataSource = list; }
/// <summary> /// Creates a DataGridTableStyle from a DataTable, sets default alignments and sizes to grid columns /// </summary> /// <param name="atable">DataTable</param> /// <param name="Parent">Parent control</param> /// <returns>Returns a DataGridTableStyle with a columns collection</returns> public static DataGridTableStyle CreateDataGridStyle(DataTable atable, Control Parent) { const decimal LOW_PERCENT = (decimal)0.90; const decimal HIGH_PERCENT = (decimal)1.10; DataGridTableStyle style = new DataGridTableStyle(false); byte r = Parent.BackColor.R; byte g = Parent.BackColor.G; byte b = Parent.BackColor.B; int sumrgb = (int)r + g + b; if (sumrgb > (128 * 3)) { r = System.Convert.ToByte(r * LOW_PERCENT); g = System.Convert.ToByte(g * LOW_PERCENT); b = System.Convert.ToByte(b * LOW_PERCENT); } else { int r1 = System.Convert.ToInt32(r * HIGH_PERCENT); int g1 = System.Convert.ToInt32(g * HIGH_PERCENT); int b1 = System.Convert.ToInt32(b * HIGH_PERCENT); if (r1 <= 255) { r = System.Convert.ToByte(r1); } else { r = 255; } if (g1 <= 255) { g = System.Convert.ToByte(g1); } else { g = 255; } if (b1 <= 255) { b = System.Convert.ToByte(b1); } else { b = 255; } } style.AlternatingBackColor = Color.FromArgb(r, g, b); style.MappingName = atable.TableName; using (Graphics gr = Parent.CreateGraphics()) { gr.PageUnit = GraphicsUnit.Pixel; foreach (DataColumn col in atable.Columns) { if (col.Caption.Length > 0) { DataGridColumnStyle cs = new DataGridTextBoxColumn(); SizeF asize; cs.HeaderText = col.Caption; string typestring = col.DataType.ToString(); asize = gr.MeasureString(StringUtil.RepeatChar('C', 10), Parent.Font); cs.Width = System.Convert.ToInt32(asize.Width); switch (typestring) { case "System.String": asize = gr.MeasureString(StringUtil.RepeatChar('C', col.MaxLength), Parent.Font); cs.Width = System.Convert.ToInt32(asize.Width); break; case "System.Decimal": case "System.Int32": case "System.Double": cs.Alignment = HorizontalAlignment.Right; break; case "System.DateTime": break; default: break; } cs.MappingName = col.ColumnName; style.GridColumnStyles.Add(cs); } } } return(style); }
private void fmEmplEdit_Load(object sender, System.EventArgs e) { DataSet sqlDS = new DataSet(); string sql = ""; try { OleDbDataAdapter sqlDA = new OleDbDataAdapter(sql, conStr); sqlDA.SelectCommand.CommandTimeout = 120; sqlDS = new dsCurrent(); sql = "SELECT ISNULL(MSURNAME, '')+' '+ISNULL(MNAME, '')+' '+ISNULL(MSECNAME, ''), " + "MDEPARTMENT AS FIO, MGROUP FROM EmplMain WHERE MCODE = '" + emplMcode + "'"; sqlDA.SelectCommand.CommandText = sql; sqlDA.Fill(sqlDS); tbFIO.Text = (string)sqlDS.Tables[2].Rows[0][0]; tbDivision.Text = sqlDS.Tables[2].Rows[0][1] as string; tbGroup.Text = Convert.ToString(sqlDS.Tables[2].Rows[0][2]); // sql="SELECT TOP 1 MPHOTO FROM EmplMain where MCODE = '" + emplMcode + "'"; // sqlDA.SelectCommand.CommandText = sql; // sqlDA.Fill(sqlDS); // byte [] photo=(Convert.IsDBNull(sqlDS.Tables[2].Rows[0][0]))?new byte[0]:(byte [])sqlDS.Tables[2].Rows[0][0]; //// if(photo.Length!=0) //// { //// MemoryStream ms=new MemoryStream(photo); //// pbPhoto.Image=new Bitmap(ms); //// lbPhoto.Hide(); //// } //// else //// { //// pbPhoto.Image=null; //// lbPhoto.Show(); //// } sql = "SELECT ISNULL(em.MSURNAME, '')+' '+ISNULL(em.MNAME, '')+' '+ISNULL(em.MSECNAME, '') AS FIO, em.MDEPARTMENT as MDEPARTMENT,em.MGROUP as MGROUP, ec.INDT as INOUTDATETIME, "; sql = sql + "CAST(DATEDIFF(mi, ec.INDT, GETDATE()) / 60 AS varchar) + ' ч. ' + CAST(DATEDIFF(mi, ec.INDT, GETDATE()) % 60 AS varchar)+' мин.' AS DUR "; sql = sql + "FROM EmplCurrent AS ec INNER JOIN EmplMain AS em ON ec.MID = em.MID WHERE em.MCODE = '" + emplMcode + "'"; sql = sql + " ORDER BY em.MSURNAME"; sqlDA.SelectCommand.CommandText = sql; sqlDA.Fill(sqlDS, "EmplEdit"); } catch (Exception e1) { MessageBox.Show(e1.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } if (sqlDS == null) { MessageBox.Show("Не удалось загрузить данные о выбранном сотруднике!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); Close(); } else { try { if (dgCurrent.TableStyles["EmplEdit"] == null) { DataGridTableStyle ts = new DataGridTableStyle(); ts.MappingName = "EmplEdit"; ts.AllowSorting = true; ts.AlternatingBackColor = Color.Honeydew; //фио DataGridTextBoxColumn tb3 = new DataGridTextBoxColumn(); tb3.Width = 150; tb3.MappingName = Convert.ToString(sqlDS.Tables["EmplEdit"].Columns[0].ColumnName); tb3.HeaderText = "ФИО"; tb3.ReadOnly = true; //отдел DataGridTextBoxColumn tb4 = new DataGridTextBoxColumn(); tb4.Width = 150; tb4.MappingName = Convert.ToString(sqlDS.Tables["EmplEdit"].Columns[1].ColumnName); tb4.HeaderText = "Отдел"; tb4.ReadOnly = true; //группа DataGridTextBoxColumn tb5 = new DataGridTextBoxColumn(); tb5.Width = 100; tb5.MappingName = Convert.ToString(sqlDS.Tables["EmplEdit"].Columns[2].ColumnName); tb5.HeaderText = "Группа"; tb5.ReadOnly = true; //время прихода DataGridTextBoxColumn tb6 = new DataGridTextBoxColumn(); tb6.Width = 120; tb6.MappingName = Convert.ToString(sqlDS.Tables["EmplEdit"].Columns[3].ColumnName); tb6.HeaderText = "Приход"; //времени на рабочем месте DataGridTextBoxColumn tb7 = new DataGridTextBoxColumn(); tb7.Width = 100; tb7.MappingName = Convert.ToString(sqlDS.Tables["EmplEdit"].Columns[4].ColumnName); tb7.HeaderText = "Отработано"; tb7.ReadOnly = true; ts.GridColumnStyles.Add(tb3); ts.GridColumnStyles.Add(tb4); ts.GridColumnStyles.Add(tb5); ts.GridColumnStyles.Add(tb6); ts.GridColumnStyles.Add(tb7); dgCurrent.TableStyles.Add(ts); dgCurrent.ReadOnly = false; } dgCurrent.SetDataBinding(sqlDS, "EmplEdit"); } catch (Exception e2) { MessageBox.Show("Ошибка при инициализации таблицы. " + e2.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } }
private void AddGridTableStyle1() { DataGridTableStyle ts = new DataGridTableStyle(); ts.MappingName = ds1.Tables[0].TableName; ts.AlternatingBackColor = Color.Beige; ts.BackColor = Color.GhostWhite; ts.ForeColor = Color.MidnightBlue; ts.GridLineColor = Color.RoyalBlue; ts.HeaderBackColor = Color.MidnightBlue; ts.HeaderForeColor = Color.Lavender; ts.SelectionBackColor = Color.Teal; ts.SelectionForeColor = Color.PaleGreen; ts.ReadOnly = false; ts.RowHeaderWidth = 10; DataGridTextBoxColumn TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "ngay"; TextCol.HeaderText = "Ngày"; TextCol.Width = 70; TextCol.ReadOnly = true; ts.GridColumnStyles.Add(TextCol); dataGrid2.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "soct"; TextCol.HeaderText = "Số CT"; TextCol.Width = 30; TextCol.ReadOnly = true; ts.GridColumnStyles.Add(TextCol); dataGrid2.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "tenkp"; TextCol.HeaderText = "Khoa"; TextCol.Width = 100; TextCol.ReadOnly = true; ts.GridColumnStyles.Add(TextCol); dataGrid2.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "no"; TextCol.HeaderText = "Nợ"; TextCol.Width = 50; TextCol.ReadOnly = true; ts.GridColumnStyles.Add(TextCol); dataGrid2.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "co"; TextCol.HeaderText = "Có"; TextCol.Width = 30; TextCol.ReadOnly = true; ts.GridColumnStyles.Add(TextCol); dataGrid2.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "diengiai"; TextCol.HeaderText = "Diễn giải"; TextCol.Width = 100; TextCol.ReadOnly = true; ts.GridColumnStyles.Add(TextCol); dataGrid2.TableStyles.Add(ts); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "sotien"; TextCol.HeaderText = "Số tiền"; TextCol.Width = 80; TextCol.Format = "###,###,###,##0.00"; TextCol.Alignment = HorizontalAlignment.Right; TextCol.ReadOnly = false; ts.GridColumnStyles.Add(TextCol); dataGrid2.TableStyles.Add(ts); }
// <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); }
// the Form load event, which displays the data in the DataGrid. private void frmDataGrid_Load(object sender, System.EventArgs e) { dgProducts.CaptionText = "Northwind Products"; dgProducts.DataSource = GetDataSource().Tables[0]; // Use a table style object to apply custom formatting to the DataGrid. DataGridTableStyle dgTableStyle1 = new DataGridTableStyle(); dgTableStyle1.AlternatingBackColor = Color.Lavender; dgTableStyle1.BackColor = Color.WhiteSmoke; dgTableStyle1.ForeColor = Color.MidnightBlue; dgTableStyle1.GridLineColor = Color.Gainsboro; dgTableStyle1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None; dgTableStyle1.HeaderBackColor = Color.MidnightBlue; dgTableStyle1.HeaderFont = new Font("Tahoma", (float)8.0, FontStyle.Bold); dgTableStyle1.HeaderForeColor = Color.WhiteSmoke; dgTableStyle1.LinkColor = Color.Teal; // Do not forget to set the MappingName property. // Without this, the DataGridTableStyle properties // and any associated DataGridColumnStyle objects // will have no effect. dgTableStyle1.MappingName = "Products"; dgTableStyle1.SelectionBackColor = Color.CadetBlue; dgTableStyle1.SelectionForeColor = Color.WhiteSmoke; // Use column style objects to apply formatting specific to each column. DataGridTextBoxColumn grdColStyle1 = new DataGridTextBoxColumn(); grdColStyle1.HeaderText = "ID#"; grdColStyle1.MappingName = "ProductID"; grdColStyle1.Width = 50; DataGridTextBoxColumn grdColStyle2 = new DataGridTextBoxColumn(); grdColStyle2.HeaderText = "Name"; grdColStyle2.MappingName = "ProductName"; grdColStyle2.Width = 225; DataGridTextBoxColumn grdColStyle3 = new DataGridTextBoxColumn(); grdColStyle3.HeaderText = "Price"; grdColStyle3.MappingName = "UnitPrice"; grdColStyle3.Width = 70; DataGridTextBoxColumn grdColStyle4 = new DataGridTextBoxColumn(); grdColStyle4.HeaderText = "# in Stock"; grdColStyle4.MappingName = "UnitsInStock"; grdColStyle4.Width = 70; // Add the column style objects to the tables style's column styles // collection. if you fail to do this the column styles will not apply. dgTableStyle1.GridColumnStyles.AddRange(new DataGridColumnStyle[] { grdColStyle1, grdColStyle2, grdColStyle3, grdColStyle4 }); // Add the table style object to the DataGrid's table styles collection. // Again, failure to add the style to the collection will cause the style // to not take effect. dgProducts.TableStyles.Add(dgTableStyle1); // Set the Form's title in the inherited Label control. lblTitle.Text = "Inherited Form with DataGrid"; }
private void AddGridTableStyle() { DataGridTableStyle ts = new DataGridTableStyle(); ts.MappingName = dt.TableName; ts.AlternatingBackColor = Color.Beige; ts.BackColor = Color.GhostWhite; ts.ForeColor = Color.MidnightBlue; ts.GridLineColor = Color.RoyalBlue; ts.HeaderBackColor = Color.MidnightBlue; ts.HeaderForeColor = Color.Lavender; ts.SelectionBackColor = Color.Teal; ts.SelectionForeColor = Color.PaleGreen; ts.ReadOnly = false; ts.RowHeaderWidth = 10; DataGridTextBoxColumn TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "stt"; TextCol.HeaderText = "STT"; TextCol.Width = 30; ts.GridColumnStyles.Add(TextCol); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "ten"; TextCol.HeaderText = "Nội dung"; TextCol.Width = 520; ts.GridColumnStyles.Add(TextCol); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "id"; TextCol.HeaderText = ""; TextCol.Width = 0; ts.GridColumnStyles.Add(TextCol); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "kho"; TextCol.HeaderText = ""; TextCol.Width = 0; ts.GridColumnStyles.Add(TextCol); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "nguon"; TextCol.HeaderText = ""; TextCol.Width = 0; ts.GridColumnStyles.Add(TextCol); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "manhom"; TextCol.HeaderText = ""; TextCol.Width = 0; ts.GridColumnStyles.Add(TextCol); TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "madoituong"; TextCol.HeaderText = ""; TextCol.Width = 0; ts.GridColumnStyles.Add(TextCol); dataGrid1.TableStyles.Add(ts); }