当前位置: 首页>>代码示例>>C#>>正文


C# Forms.DataGridViewCellStyle类代码示例

本文整理汇总了C#中System.Windows.Forms.DataGridViewCellStyle的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewCellStyle类的具体用法?C# DataGridViewCellStyle怎么用?C# DataGridViewCellStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DataGridViewCellStyle类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridViewCellStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Paint

 protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
 {
     var buttonRectangle = new Rectangle(cellBounds.X + 2, cellBounds.Y + 2, cellBounds.Width - 4, cellBounds.Height - 4);
     base.Paint(graphics, clipBounds, buttonRectangle, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
     var imageRectangle = new Rectangle(cellBounds.X + 6, cellBounds.Y + 6, _detailImage.Width, _detailImage.Height);
     graphics.DrawImage(_detailImage, imageRectangle);
 }
开发者ID:pragmasolutions,项目名称:Libreria,代码行数:7,代码来源:DetailsColumn.cs

示例2: SetRowDefaultCellStyle

        /// <summary>
        /// 设置行样式
        /// </summary>
        /// <param name="dgvCellStyle"></param>
        public void SetRowDefaultCellStyle(DataGridViewCellStyle dgvCellStyle)
        {
            if (dgvCellStyle == null)
                return;

            textdataGrid.DefaultCellStyle = dgvCellStyle;
        }
开发者ID:keep01,项目名称:efwplus_winformframe,代码行数:11,代码来源:CardDataGrid.cs

示例3: InitializeEditingControl

        public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
            DataGridViewFADateTimePickerEditor editor = Editor;

            if (editor != null)
            {
                var column = GetColumn();

                editor.RightToLeft = DataGridView.RightToLeft;
                editor.Theme = column.Theme;

                var formattedValue = initialFormattedValue.ToString();

                if (string.IsNullOrEmpty(formattedValue))
                {
                    editor.SelectedDateTime = DateTime.Now;
                    editor.mv.MonthViewControl.SetNoneDay();
                }
                else
                {
                    editor.SelectedDateTime = GetParsedDate(formattedValue);
                }
            }
        }
开发者ID:HEskandari,项目名称:FarsiLibrary,代码行数:25,代码来源:DataGridViewFADateTimePickerColumn.cs

示例4: ApplyColors

        private void ApplyColors()
        {
            foreach (DataGridViewRow dgRow in dgViewResults.Rows)
            {
                DataGridViewCellStyle styleRed = new DataGridViewCellStyle();
                styleRed.ForeColor = Color.Red;

                DataGridViewCellStyle styleGreen = new DataGridViewCellStyle();
                styleGreen.ForeColor = Color.Green;

                DataGridViewCellStyle styleYellow = new DataGridViewCellStyle();
                styleYellow.ForeColor = Color.Orange;

                if (Convert.ToInt32(dgRow.Cells[1].Value) <= 3)
                {
                    dgRow.DefaultCellStyle = styleRed;
                }
                else if (Convert.ToInt32(dgRow.Cells[1].Value) == 5)
                {
                    dgRow.DefaultCellStyle = styleGreen;
                }
                else
                {
                    dgRow.DefaultCellStyle = styleYellow;
                }
            }
        }
开发者ID:Jim-1960,项目名称:mkv-chapterizer,代码行数:27,代码来源:ChapterDB.cs

示例5: InitializeEditingControl

 public override void InitializeEditingControl(int rowIndex, object
     initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
 {
     try
     {
         // Set the value of the editing control to the current cell value. 
         base.InitializeEditingControl(rowIndex, initialFormattedValue,
             dataGridViewCellStyle);
         CalendarEditingControl ctl =
             DataGridView.EditingControl as CalendarEditingControl;
         // Use the default row value when Value property is null. 
         if (this.Value == null)
         {
             ctl.Value = (DateTime)this.DefaultNewRowValue;
         }
         else
         {
             ctl.Value = (DateTime)this.Value;
         }
     }
     catch (Exception ex)
     {
         GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
     }
 }
开发者ID:sumitglobussoft,项目名称:Instagram-PVA-BOT,代码行数:25,代码来源:AddDateTimePickerInGRV.cs

示例6: Paint

        //绘制列头checkbox
        protected override void Paint(System.Drawing.Graphics graphics,
                                      System.Drawing.Rectangle clipBounds,
                                      System.Drawing.Rectangle cellBounds,
                                      int rowIndex,
                                      DataGridViewElementStates dataGridViewElementState,
                                      object value,
                                      object formattedValue,
                                      string errorText,
                                      DataGridViewCellStyle cellStyle,
                                      DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex,
                        dataGridViewElementState, value,
                        formattedValue, errorText, cellStyle,
                        advancedBorderStyle, paintParts);

            Point p = new Point();
            Size s = CheckBoxRenderer.GetGlyphSize(graphics,
            System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal);
            p.X = cellBounds.Location.X + (cellBounds.Width / 2) - (s.Width / 2) - 1;//列头checkbox的X坐标
            p.Y = cellBounds.Location.Y + (cellBounds.Height / 2) - (s.Height / 2);//列头checkbox的Y坐标
            _cellLocation = cellBounds.Location;
            checkBoxLocation = p;
            checkBoxSize = s;
            if (_checked)
                _cbState = CheckBoxState.CheckedNormal;
            else
                _cbState = CheckBoxState.UncheckedNormal;
            CheckBoxRenderer.DrawCheckBox(graphics, checkBoxLocation, _cbState);
        }
开发者ID:linyc,项目名称:CTool,代码行数:32,代码来源:DataGridViewCheckBoxHeaderCell.cs

示例7: GetFormattedValue

        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            Guid obj = (Guid) value;
            string val = PaymentController.GetInstance().GetCustomer(obj).ToString();

            return val;
        }
开发者ID:altmer,项目名称:study-projects,代码行数:7,代码来源:CustomerIDColumn.cs

示例8: SchedulerWindow

        public SchedulerWindow()
        {
            _warningsToDeploy = new List<DisplayEvent>();
            _deployedWarnings = new List<DisplayEvent>();
            _buttonToEventLookup = new Dictionary<int, Tuple<string, DateTime>>();
            _scheduler = new Scheduler();

            InitializeComponent();
            this.MaximizeBox = false;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;

            UpdateSchedulerTable(fieldEdited: true);
            UpdateCalendar();

            ClearEventDetails();

            _dailyReminderTask = new Task(DailyReminder);
            _dailyReminderTask.Start();

            _urgentStyle = new DataGridViewCellStyle();
            _urgentStyle.BackColor = Color.LightPink;
            _urgentStyle.SelectionBackColor = Color.LightPink;
            _warningStyle = new DataGridViewCellStyle();
            _warningStyle.BackColor = Color.LightYellow;
            _warningStyle.SelectionBackColor = Color.LightYellow;
            _defaultStyle = new DataGridViewCellStyle();
            _defaultStyle.BackColor = Color.LightGreen;
            _defaultStyle.SelectionBackColor = Color.LightGreen;
            EventTable.ClearSelection();
        }
开发者ID:GorelH,项目名称:Scheduler,代码行数:30,代码来源:SchedulerWindow.cs

示例9: Form1

        public Form1()
        {
            InitializeComponent();
            lctrl = new LoanCtrl();
            // To get the right list enter string name of the list, this is made for direct access
            // to the list so the checkboxes respond directly
            dataGridView1.DataSource = lctrl.GetDirectList("loans");
            dataGridView1.BackgroundColor = Color.Silver;
            dataGridView1.Columns[3].Visible = true;
            dataGridView1.Columns[0].ReadOnly = true;
            dataGridView1.Columns[1].ReadOnly = true;
            dataGridView1.Columns[2].ReadOnly = true;

            DataGridViewCellStyle style = new DataGridViewCellStyle();
            DataGridViewCellStyle styleHeader = new DataGridViewCellStyle();
            style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            styleHeader.Alignment = DataGridViewContentAlignment.MiddleCenter;
            styleHeader.Padding = new Padding(20, 0, 0, 0);
            dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.LightGray;
            dataGridView1.EnableHeadersVisualStyles = false;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.RowsDefaultCellStyle.SelectionBackColor = Color.DeepSkyBlue;
            dataGridView1.RowsDefaultCellStyle.SelectionForeColor = Color.Black;
            dataGridView1.RowHeadersVisible = false;
            foreach (DataGridViewColumn column in dataGridView1.Columns)
            {
                column.HeaderCell.Style = styleHeader;
                column.DefaultCellStyle = style;
            }
            dataGridView1.Columns[3].HeaderCell.Style = style;
        }
开发者ID:janix89,项目名称:DebtsAccounting,代码行数:31,代码来源:Form1.cs

示例10: PaintBackGround

 private void PaintBackGround(Graphics graphics, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewCellStyle cellStyle, Rectangle cellBounds) {
     Rectangle rectangle = base.BorderWidths(advancedBorderStyle);
     Rectangle rect = cellBounds;
     rect.Offset(rectangle.X, rectangle.Y);
     rect.Width -= rectangle.Right;
     rect.Height -= rectangle.Bottom;
     using(SolidBrush brush = new SolidBrush(cellStyle.BackColor)) {
         graphics.FillRectangle(brush, rect);
     }
     if(this.lFileSize <= 0L) {
         return;
     }
     Rectangle bounds = rect;
     double num = ((double)this.progressValue) / ((double)this.lFileSize);
     bounds.Width = (int)(bounds.Width * num);
     if(VisualStyleRenderer.IsSupported) {
         try {
             new VisualStyleRenderer(VisualStyleElement.ProgressBar.Chunk.Normal).DrawBackground(graphics, bounds);
             goto Label_00E1;
         }
         catch {
             goto Label_00E1;
         }
     }
     using(SolidBrush brush2 = new SolidBrush(SystemColors.Highlight)) {
         graphics.FillRectangle(brush2, bounds);
     }
 Label_00E1:
     using(StringFormat format = new StringFormat()) {
         format.Alignment = format.LineAlignment = StringAlignment.Center;
         using(SolidBrush brush3 = new SolidBrush(cellStyle.ForeColor)) {
             graphics.DrawString(((int)(num * 100.0)) + "%", cellStyle.Font, brush3, rect, format);
         }
     }
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:35,代码来源:DataGridViewProgressBarCell.cs

示例11: Paint

 protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
     if(this.fNowCalculating) {
         this.PaintBackGround(graphics, advancedBorderStyle, cellStyle, cellBounds);
         paintParts &= ~(DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.Background);
     }
     base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:7,代码来源:DataGridViewProgressBarCell.cs

示例12: InitializeEditingControl

 public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
 {
     // Set the value of the editing control to the current cell value.
     base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
     MonthPaidControl ctl = DataGridView.EditingControl as MonthPaidControl;
     ctl.Value = (DateTime)GetValue(rowIndex);
 }
开发者ID:altmer,项目名称:study-projects,代码行数:7,代码来源:MonthPaidColumn.cs

示例13: DataGridViewRowPostPaintEventArgs

 /// <include file='doc\DataGridViewRowPostPaintEventArgs.uex' path='docs/doc[@for="DataGridViewRowPostPaintEventArgs.DataGridViewRowPostPaintEventArgs"]/*' />
 public DataGridViewRowPostPaintEventArgs(DataGridView dataGridView,
                                          Graphics graphics, 
                                          Rectangle clipBounds, 
                                          Rectangle rowBounds,
                                          int rowIndex,
                                          DataGridViewElementStates rowState,
                                          string errorText,
                                          DataGridViewCellStyle inheritedRowStyle,
                                          bool isFirstDisplayedRow,
                                          bool isLastVisibleRow)
 {
     if (dataGridView == null)
     {
         throw new ArgumentNullException("dataGridView");
     }
     if (graphics == null)
     {
         throw new ArgumentNullException("graphics");
     }
     if (inheritedRowStyle == null)
     {
         throw new ArgumentNullException("inheritedRowStyle");
     }
     this.dataGridView = dataGridView;
     this.graphics = graphics;
     this.clipBounds = clipBounds;
     this.rowBounds = rowBounds;
     this.rowIndex = rowIndex;
     this.rowState = rowState;
     this.errorText = errorText;
     this.inheritedRowStyle = inheritedRowStyle;
     this.isFirstDisplayedRow = isFirstDisplayedRow;
     this.isLastVisibleRow = isLastVisibleRow;
 }
开发者ID:JianwenSun,项目名称:cc,代码行数:35,代码来源:DataGridViewRowPostPaintEventArgs.cs

示例14: MapPackageManager

        public MapPackageManager(Form1 formRef)
        {
            InitializeComponent();
            mainForm = formRef;

            // Get list of maps from server
            using (WebClient wc = new WebClient())
            {
                var json = wc.DownloadString("http://hack.fyi/rlmaps/maps.json");

                List<MapPackageJson> maps  = JsonConvert.DeserializeObject<List<MapPackageJson>>(json);

                foreach(MapPackageJson mpj in maps)
                {
                    mapPackages.Add(mpj.mapPackage);
                }
            }

            dataGridView1.DataSource = mapPackages;
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
            dataGridView1.Columns["FileUrl"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.RowsDefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent;
            DataGridViewCellStyle columnHeaderStyle = new DataGridViewCellStyle();
            columnHeaderStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

            dataGridView1.ColumnHeadersDefaultCellStyle = columnHeaderStyle;

            packageStatusLabel.Text = "Downloaded initial map list.";
        }
开发者ID:timunrue,项目名称:RLMapLoader,代码行数:30,代码来源:MapPackageManager.cs

示例15: GetStatusRowStyle

        /// <summary>
        /// 状态行样式
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public DataGridViewCellStyle GetStatusRowStyle(int s)
        {
            DataGridViewCellStyle dr = new DataGridViewCellStyle();

            switch (s)
            {
                case 1://放送中
                    dr.ForeColor = Color.White;
                    dr.BackColor = Color.Navy;

                    break;
                case 2://完结
                    dr.ForeColor = Color.FromArgb(0, 97, 0);
                    dr.BackColor = Color.FromArgb(198, 239, 206);
                    break;
                case 3://新企划
                    dr.ForeColor = Color.DarkRed;
                    dr.BackColor = Color.LightPink;
                    break;
                case 9://弃置
                    dr.ForeColor = Color.Black;
                    dr.BackColor = Color.LightGray;
                    break;
            }
            return dr;
        }
开发者ID:kirisamex,项目名称:Animedata,代码行数:31,代码来源:StatusStyle.cs


注:本文中的System.Windows.Forms.DataGridViewCellStyle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。