在dataGridView上鼠标经过时,会提示这个单元格的内容,但是可能因为我的数据库中的数据类型字节数太长,显示的框就很长,有没有办法可以让它自动适应,还有这个鼠标经过会有提示的功能叫什么功能?如图:

解决方案 »

  1.   


    //参考
    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();
            }
      

  2.   

    你是说里面控件的ToolTip属性鼠标移上去显示提示的?