| FlexGrid for WinForms Task-Based Help > Adding ToolTips That Display UserData > UserData ToolTips for a Cell Range |
To add ToolTips that display UserData for a cell range, use C1FlexGrid's MouseMove event to get the CellRange.UserData property and display it in a ToolTip control.
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
' Set the cell range that contains the non-metallic elements. Dim rng As C1.Win.C1FlexGrid.CellRange = Me.C1FlexGrid1.GetCellRange(6, 1, 10, 10) ' Set the background color to see the cell range more easily. rng.StyleNew.BackColor = Color.AliceBlue ' Set the user data for the cell range. rng.UserData = "Non-Metallic" |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
// Set the cell range that contains the non-metallic elements. C1.Win.C1FlexGrid.CellRange rng = this.c1FlexGrid1.GetCellRange(6, 1, 10, 10); // Set the background color to see the cell range more easily. rng.StyleNew.BackColor = Color.AliceBlue; // Set the user data for the cell range. rng.UserData = "Non-Metallic"; |
|
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
tip = Me.C1FlexGrid1.GetUserData(C1FlexGrid1.MouseRow, C1FlexGrid1.MouseCol)
ToolTip1.SetToolTip(C1FlexGrid1, tip)
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void c1FlexGrid1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
string tip;
tip = (string)this.c1FlexGrid1.GetUserData(c1FlexGrid1.MouseRow, c1FlexGrid1.MouseCol);
toolTip1.SetToolTip(c1FlexGrid1, tip);
}
|
|
The ToolTip appears within the entire cell range.