FlexGrid for WinForms Task-Based Help > Adding ToolTips That Display UserData > UserData ToolTips for a Cell Style |
To add ToolTips that display UserData for a cell style, use C1FlexGrid's MouseMove event to get the CellStyle.UserData property and display it in a ToolTip control.
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
' Create a CellStyle for columns. Dim cc As C1.Win.C1FlexGrid.CellStyle cc = Me.C1FlexGrid1.Styles.Add("ColumnColor") cc.BackColor = Color.Cornsilk ' Add UserData with the style name. cc.UserData = "ColumnColor Style" ' Create a CellStyle for rows. Dim rs As C1.Win.C1FlexGrid.CellStyle rs = Me.C1FlexGrid1.Styles.Add("RowColor") rs.BackColor = Color.PowderBlue ' Add UserData with the style name. rs.UserData = "RowColor Style" ' Assign the ColumnColor Style to a column. Me.C1FlexGrid1.Cols(2).Style = Me.C1FlexGrid1.Styles("ColumnColor") ' Assign the RowColor Style to a row. Me.C1FlexGrid1.Rows(8).Style = Me.C1FlexGrid1.Styles("RowColor") |
To write code in C#
C# |
Copy Code
|
---|---|
// Create a CellStyle for columns. C1.Win.C1FlexGrid.CellStyle cc; cc = this.c1FlexGrid1.Styles.Add("ColumnColor"); cc.BackColor = Color.Cornsilk; // Add UserData with the style name. cc.UserData = "ColumnColor Style"; // Create a CellStyle for rows. C1.Win.C1FlexGrid.CellStyle rs; rs = this.c1FlexGrid1.Styles.Add("RowColor"); rs.BackColor = Color.PowderBlue; // Add UserData with the style name. rs.UserData = "RowColor Style"; // Assign the ColumnColor Style to a column. this.c1FlexGrid1.Cols[2].Style = this.c1FlexGrid1.Styles["ColumnColor"]; // Assign the RowColor Style to a row. this.c1FlexGrid1.Rows[8].Style = this.c1FlexGrid1.Styles["RowColor"]; |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub C1FlexGrid1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles C1FlexGrid1.MouseMove Dim tip As String If C1FlexGrid1.MouseCol <> C1FlexGrid1.Cols.Fixed - 1 And C1FlexGrid1.MouseRow <> C1FlexGrid1.Rows.Fixed - 1 Then tip = C1FlexGrid1.Cols(C1FlexGrid1.MouseCol).Style.UserData ToolTip1.SetToolTip(C1FlexGrid1, tip) End If End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void c1FlexGrid1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { string tip; if (c1FlexGrid1.MouseCol != c1FlexGrid1.Cols.Fixed - 1 & c1FlexGrid1.MouseRow != c1FlexGrid1.Rows.Fixed - 1) { tip = (string)c1FlexGrid1.Cols[c1FlexGrid1.MouseCol].Style.UserData; toolTip1.SetToolTip(c1FlexGrid1, tip); } } |
The ToolTip appears within the CellStyle.