当单元格内容太多时,则会忽略后面的内容
解决方案:
添加Dgv鼠标移到单元格事件时,设置当前单元格的ToolTipText属性内容为当前单元格内容
void From_Load(object sender, EventArgs e) { this.dgvSystemLog.ShowCellToolTips = true; this.dgvSystemLog.CellMouseEnter += new DataGridViewCellEventHandler(dgvSystemLog_CellMouseEnter); } /// <summary> /// 鼠标移到单元格时,设置当前单元格的ToolTipText属性内容为当前单元格内容 /// 解决tip内容显示不全的问题 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void dgvSystemLog_CellMouseEnter(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0 || dgvSystemLog.Rows.Count <= 0) return; dgvSystemLog.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = (dgvSystemLog.Rows[e.RowIndex].Cells[e.ColumnIndex].Value ?? string.Empty).ToString(); }
更改后的效果:
参考:http://*.com/questions/22626802/how-to-increase-the-length-of-tooltip-in-datagridview-in-winforms