Esempio n. 1
0
        private void AddGridTableStyle1()
        {
            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 = "mabd";
            TextCol.HeaderText  = "";
            TextCol.Width       = 0;
            ts.GridColumnStyles.Add(TextCol);
            dataGrid2.TableStyles.Add(ts);

            TextCol             = new DataGridTextBoxColumn();
            TextCol.MappingName = "stt";
            TextCol.HeaderText  = "Stt";
            TextCol.Width       = 30;
            ts.GridColumnStyles.Add(TextCol);
            dataGrid2.TableStyles.Add(ts);

            TextCol             = new DataGridTextBoxColumn();
            TextCol.MappingName = "ma";
            TextCol.HeaderText  = "Mã";
            TextCol.Width       = 100;
            TextCol.ReadOnly    = true;
            ts.GridColumnStyles.Add(TextCol);
            dataGrid2.TableStyles.Add(ts);

            TextCol             = new DataGridTextBoxColumn();
            TextCol.MappingName = "ten";
            TextCol.HeaderText  = "Tên";
            TextCol.Width       = 250;
            TextCol.ReadOnly    = true;
            ts.GridColumnStyles.Add(TextCol);
            dataGrid2.TableStyles.Add(ts);

            TextCol             = new DataGridTextBoxColumn();
            TextCol.MappingName = "dang";
            TextCol.HeaderText  = "ĐVT";
            TextCol.Width       = 50;
            TextCol.ReadOnly    = true;
            ts.GridColumnStyles.Add(TextCol);
            dataGrid2.TableStyles.Add(ts);

            TextCol             = new DataGridTextBoxColumn();
            TextCol.MappingName = "tenhc";
            TextCol.HeaderText  = "Hoạt chất";
            TextCol.Width       = 200;
            TextCol.ReadOnly    = true;
            ts.GridColumnStyles.Add(TextCol);
            dataGrid2.TableStyles.Add(ts);

            TextCol             = new DataGridTextBoxColumn();
            TextCol.MappingName = "soluong";
            TextCol.HeaderText  = "Số lượng";
            TextCol.Width       = 50;
            TextCol.ReadOnly    = false;
            ts.GridColumnStyles.Add(TextCol);
            dataGrid2.TableStyles.Add(ts);

            TextCol             = new DataGridTextBoxColumn();
            TextCol.MappingName = "cachdung";
            TextCol.HeaderText  = "Cách dùng";
            TextCol.Width       = 170;
            TextCol.ReadOnly    = false;
            ts.GridColumnStyles.Add(TextCol);
            dataGrid2.TableStyles.Add(ts);

            //TextCol = new DataGridTextBoxColumn();
            //TextCol.MappingName = "doituong";
            //TextCol.HeaderText = "Đối tượng";
            //TextCol.Width = 100;
            //TextCol.ReadOnly = false;
            //ts.GridColumnStyles.Add(TextCol);
            //dataGrid2.TableStyles.Add(ts);

            DataGridComboBoxColumn ComCol = new DataGridComboBoxColumn(dtdoituong, 1, 1);

            ComCol.MappingName    = "doituong";
            ComCol.HeaderText     = "Đối tượng";
            ComCol.Width          = 100;
            ComCol.ReadOnly       = false;
            ComCol.Alignment      = HorizontalAlignment.Left;
            ComCol.NullText       = string.Empty;
            dataGrid1.CaptionText = string.Empty;
            ts.GridColumnStyles.Add(ComCol);
            dataGrid2.TableStyles.Add(ts);
        }
Esempio n. 2
0
        private void AddGridTableStyle()
        {
            DataGridTableStyle ts = new DataGridTableStyle();

            ts.MappingName          = dsdm.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.FromArgb(0, 255, 255);
            ts.SelectionForeColor   = Color.PaleGreen;
            ts.RowHeaderWidth       = 5;

            FormattableBooleanColumn discontinuedCol = new FormattableBooleanColumn();

            discontinuedCol.MappingName = "chon";
            discontinuedCol.HeaderText  = "Chọn";
            discontinuedCol.Width       = 30;
            discontinuedCol.AllowNull   = false;

            discontinuedCol.SetCellFormat    += new FormatCellEventHandler(SetCellFormat);
            discontinuedCol.BoolValueChanged += new BoolValueChangedEventHandler(BoolValueChanged);
            ts.GridColumnStyles.Add(discontinuedCol);
            dataGrid1.TableStyles.Add(ts);

            FormattableTextBoxColumn TextCol = new FormattableTextBoxColumn();

            TextCol.MappingName    = "ma";
            TextCol.HeaderText     = "Mã";
            TextCol.Width          = 100;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "ten";
            TextCol.HeaderText     = "Tên";
            TextCol.Width          = 365;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "dang";
            TextCol.HeaderText     = "ĐVT";
            TextCol.Width          = 50;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "tenhc";
            TextCol.HeaderText     = "Hoạt chất";
            TextCol.Width          = 200;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            DataGridComboBoxColumn ComCol = new DataGridComboBoxColumn(dtdoituong, 1, 1);

            ComCol.MappingName    = "doituong";
            ComCol.HeaderText     = "Đối tượng";
            ComCol.Width          = 100;
            ComCol.ReadOnly       = false;
            ComCol.Alignment      = HorizontalAlignment.Left;
            ComCol.NullText       = string.Empty;
            dataGrid1.CaptionText = string.Empty;
            ts.GridColumnStyles.Add(ComCol);
            dataGrid1.TableStyles.Add(ts);

            //ts.GridColumnStyles.Add(new DataGridComboBoxColumn(dtdoituong, "doituong", "madoituong"));
            //ts.GridColumnStyles[6].MappingName = "tenkp";
            //ts.GridColumnStyles[6].HeaderText = "Chuyển phòng";
            //ts.GridColumnStyles[6].Width = 160;
            //ts.GridColumnStyles[6].Alignment = HorizontalAlignment.Left;
            //ts.GridColumnStyles[6].NullText = string.Empty;
            //dataGrid1.CaptionText = string.Empty;
        }