C# Winform DataGridView 头部行高自动适应文本
//头部行高自动适应 DGV.ColumnWidthChanged += DGV_ColumnWidthChanged; /// <summary> /// DataGridView 头部行高自动适应文本 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DGV_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { var dgv = (DataGridView)sender; dgv.ColumnWidthChanged -= DGV_ColumnWidthChanged; try { if (sender is DataGridView) { //var dgv = (DataGridView)sender; Task.Run(() => { Thread.Sleep(1000); dgv.BeginInvoke(new Action(() => { dgv.AutoResizeColumnHeadersHeight(); dgv.ColumnWidthChanged += DGV_ColumnWidthChanged; })); }); } } catch (Exception ex) { } }
标签:sender,DataGridView,dgv,行高,DGV,文本,ColumnWidthChanged From: https://www.cnblogs.com/orp1989/p/18121581