简体   繁体   中英

Align the text in datagrid view in winforms

在 c# winforms 中,我需要在 DataGridView 列标题中绘制文本,由于排序字形,我无法将文本居中对齐,如何将文本绘制为根据单元格宽度居中对齐。我不想删除排序功能,但我需要删除排序字形的空间

Try following

this.dgData.Columns["Name"].DefaultCellStyle.Alignment = 
DataGridViewContentAlignment.MiddleCenter;

try this

foreach(DataGridViewColumn col in dgvBreakDowns.Columns)
{
col.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;   
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM