Example #1
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    = "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     = "Hãng";
            TextCol.Width          = 305;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);
        }
Example #2
0
        private void AddGridTableStyle()
        {
            DataGridTableStyle ts = new DataGridTableStyle();

            ts.MappingName          = ds.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    = "sophieu";
            TextCol.HeaderText     = "Số phiếu";
            TextCol.Width          = 60;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "ngaysp";
            TextCol.HeaderText     = "Ngày";
            TextCol.Width          = 65;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "sohd";
            TextCol.HeaderText     = "Số hóa đơn";
            TextCol.Width          = 100;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "ngayhd";
            TextCol.HeaderText     = "Ngày";
            TextCol.Width          = 65;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "madv";
            TextCol.HeaderText     = "Nhà cung cấp";
            TextCol.Width          = 180;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "no";
            TextCol.HeaderText     = "Nợ";
            TextCol.Width          = 50;
            TextCol.ReadOnly       = false;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "co";
            TextCol.HeaderText     = "Có";
            TextCol.Width          = 50;
            TextCol.ReadOnly       = false;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "sotien";
            TextCol.HeaderText     = "Số tiền";
            TextCol.Width          = 70;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);

            TextCol                = new FormattableTextBoxColumn();
            TextCol.MappingName    = "datra";
            TextCol.HeaderText     = "Đã trả";
            TextCol.Width          = 70;
            TextCol.ReadOnly       = true;
            TextCol.SetCellFormat += new FormatCellEventHandler(SetCellFormat);
            ts.GridColumnStyles.Add(TextCol);
            dataGrid1.TableStyles.Add(ts);
        }