When using DataGrid, you often encounter the content of the content in the cell, which causes the text to go to the text, which makes the simple page look very chaotic. The following method can solve this problem.
When the content of the cell exceeds the specified length, the excess words are intercepted, and then all content is displayed when the mouse is on a certain cell.
This method has a disadvantage: each unit is both a specified length.
// A DataGrid ItemDatabase.
// Part of the upper half sets the background color when the mouse hover
// The lower half is only role
Public void DataGrid1_itemdatabase (Object Sender, DataGriditeMeventArgs E)
{
IF (E.Item.ItemType == ListItemType.Item || E.Item.ItemType == ListItemType.alternatingItem)
{
Color color = this.dataGrid1.selectedItemStyle.ForeColor;
String forecolor = string.format ("# {0: x2} {1: x2} {2: x2}", color.r, color.g, color.b);
Color = this.dataGrid1.selectedItemStyle.backcolor;
String backcolor = string.format ("# {0: x2} {1: x2} {2: x2}", color.r, color.g, color.b);
// If you do not set the color of the selected item, the mouse effect is not set.
IF (Forecolor! = "# 000000" || backcolor! = "# 000000")
{
e.Item.Attributes.Add ( "onmouseover", string.Format ( "oldItemForeColor = this.style.color; this.style.color = '{0}'; oldItemBackColor = this.style.backgroundColor; this.style.backgroundColor = '{1}' ", forecolor, backcolor);
E.Item.attributes.add ("onmouseout", "this.style.color = OldItemForeColor; this.style.BackgroundColor = OldItemBackColor;");
}
E.Item.cells [1] .Text = "