1 public void DataViewShow(GridView GV, int showLenth) 2 { 3 GridViewRow currentRow; 4 for (int i = 0; i < GV.Rows.Count; i++) 5 { 6 currentRow = GV.Rows[i]; 7 for (int j = 0; j < GV.Columns.Count; j++) 8 { 9 currentRow.Cells[j].ToolTip = currentRow.Cells[j].Text; 10 TableCell currentColl = currentRow.Cells[j]; 11 if ((currentColl.Text).Length > showLenth) 12 { 13 currentColl.Text = (currentColl.Text).Substring(0, showLenth) + "..."; 14 } 15 } 16 } 17 }
dataGridview 數據太長無法完全顯示,可調用一下方法優化
該方法指定dataGridview顯示字符長度,數據放在單元格上時顯示全部數據