datagridview alternatingrow alignment
问题描述:
在我的项目中,我读取一个csv文件并将其存储在DataTable中,然后将其显示在DataGridView中。但我想,该值对准到在第2列右侧的列,所以我写:datagridview alternatingrow alignment
grigliavenduto.Columns[2].DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleRight;
但这恰好一列,但不是未来,一种是否是否是否。 ...所以我怎么可以通过代码来设置列的AlternatingRowsDefaultCellStyle 2右侧的对齐?谢谢
答
你也可以设置属性:grigliavenduto.Columns[2].AlternatingCellStyle
与上面相同,这可能会工作。
但我认为应该有一个属性影响正常和交替行,看看DataGridView的属性和玩一下。
答
我不认为你可以指定一个备用的风格为特定的列,而不是你能尝试CellFormatting事件
void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == [your index])
{
//conditions and then set like e,RowIndex % 2 == 0
e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
}
}
+0
@Blackguardian完成了这项工作?> – V4Vendetta 2011-04-07 08:33:16
它不AlternatingCellStyle工作,我不找到该物业 – Blackguardian 2011-03-09 15:42:06