dataGridView 的 DefaultCellStyle.Format 属性,怎么设置
展开全部
通过修改DataGridView.RowHeadersVisible属性取消第一列,把此属性设置为true,第一列不再显示。如下图所示:DataGridView.RowHeadersVisible属性获取或设置一个值,该值指示是否显示包含行标题的列。属性值Type:System.Boolean如果显示包含行标题的列,为true;否则为false。默认值为true。备注如果RowHeadersVisible属性是false,,一行其Resizable属性设置为true仍可调整大小在用户界面(UI)中通过单击鼠标光标要调整大小的行的下边框的任意位置。示例private void SetUpDataGridView(){ this.Controls.Add(dataGridView1); dataGridView1.ColumnCount = 5; DataGridViewCellStyle style = dataGridView1.ColumnHeadersDefaultCellStyle; style.BackColor = Color.Navy; style.ForeColor = Color.White; style.Font = new Font(dataGridView1.Font, FontStyle.Bold); dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter; dataGridView1.Name = "dataGridView1"; dataGridView1.Location = new Point(8, 8); dataGridView1.Size = new Size(500, 300); dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders; dataGridView1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Raised; dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.Single; dataGridView1.GridColor = SystemColors.ActiveBorder; dataGridView1.RowHeadersVisible = false; dataGridView1.Columns[0].Name = "Release Date"; dataGridView1.Columns[1].Name = "Track"; dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Columns[2].Name = "Title"; dataGridView1.Columns[3].Name = "Artist"; dataGridView1.Columns[4].Name = "Album"; // Make the font italic for row four. dataGridView1.Columns[4].DefaultCellStyle.Font = new Font(DataGridView.DefaultFont, FontStyle.Italic); dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.MultiSelect = false; dataGridView1.BackgroundColor = Color.Honeydew; dataGridView1.Dock = DockStyle.Fill; dataGridView1.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting); dataGridView1.CellParsing += new DataGridViewCellParsingEventHandler(dataGridView1_CellParsing); addNewRowButton.Click += new EventHandler(addNewRowButton_Click); deleteRowButton.Click += new EventHandler(deleteRowButton_Click); ledgerStyleButton.Click += new EventHandler(ledgerStyleButton_Click); dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating);}
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询