在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
DataGridView 给标题列增加序号 private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { DataGridViewTextBoxColumn dgv_Text = new DataGridViewTextBoxColumn(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { int j = i + 1; dataGridView1.Rows[i].HeaderCell.Value = j.ToString(); } } 格式化某个字段 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if ( e == null || e.Value == null || !(sender is DataGridView) ) { return; } DataGridView dgv = (DataGridView)sender; object originalValue = e.Value; if(dgv.Columns[e.ColumnIndex].DataPropertyName == "操作类型") { e.Value = ((int)originalValue == 1) ? "缴费" : "退费"; } if (e.ColumnIndex == dgv.Columns["Apply_Date"].Index) //格式化日期 { if (e.Value != null) { e.Value = Convert.ToDateTime(e.Value).ToString("yyyy-M-d"); } } } 转载自:http://blog.csdn.net/hfzsjz/article/details/3590319 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论