在dataGridView上鼠标经过时,会提示,叫什么功能 在dataGridView上鼠标经过时,会提示这个单元格的内容,但是可能因为我的数据库中的数据类型字节数太长,显示的框就很长,有没有办法可以让它自动适应,还有这个鼠标经过会有提示的功能叫什么功能?如图: 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //参考void dataGridView1_CellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e) { if (e.ColumnIndex == -1 || e.RowIndex == -1) { return; } StringBuilder tipText = new StringBuilder(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()); int rowLength = 20; int totalLength = tipText.Length; if (totalLength > rowLength) { int startIndex = rowLength; for (int i = 0; i <= totalLength / rowLength; i++) { if (startIndex > totalLength) { break; } tipText.Insert(startIndex, "\r\n"); startIndex += rowLength + 2; } } e.ToolTipText = tipText.ToString(); } 你是说里面控件的ToolTip属性鼠标移上去显示提示的? C#窗体调用 IE浏览器 C#析構函數的問題. Tab键的ASCII码是多少? 输入验证的问题 关于listView控件的问题.急.高手帮忙 两天了,这个问题都没有解决,不知道是不是我问的不清楚啊 关于ComboBox问题,急啊! 【求助】winform下怎么导入加密的excel文件? 在C#中怎样动态创建WORD文档、EXCEL文档? 图片切割算法求解 怎么给工具栏中的按钮设置快捷键?
//参考
void dataGridView1_CellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e)
{
if (e.ColumnIndex == -1 || e.RowIndex == -1)
{
return;
} StringBuilder tipText = new StringBuilder(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
int rowLength = 20;
int totalLength = tipText.Length; if (totalLength > rowLength)
{
int startIndex = rowLength; for (int i = 0; i <= totalLength / rowLength; i++)
{
if (startIndex > totalLength)
{
break;
} tipText.Insert(startIndex, "\r\n");
startIndex += rowLength + 2;
}
} e.ToolTipText = tipText.ToString();
}