public SetToolTip ( Control control, string caption ) : void | ||
control | Control | |
caption | string | |
return | void |
Button myButton = new Button(); myButton.Text = "Click here"; myButton.Location = new Point(10, 10); this.Controls.Add(myButton); ToolTip myToolTip = new ToolTip(); myToolTip.SetToolTip(myButton, "This button will perform an action when clicked");
DataGridView myGrid = new DataGridView(); myGrid.ColumnCount = 2; myGrid.Rows.Add("Apple", "Fruit"); myGrid.Rows.Add("Carrot", "Vegetable"); myGrid.Location = new Point(10, 50); this.Controls.Add(myGrid); ToolTip myToolTip = new ToolTip(); foreach (DataGridViewRow row in myGrid.Rows) { myToolTip.SetToolTip(row.Cells[0], $"This is a {row.Cells[1].Value.ToString()}"); }In this example, a DataGridView control is created and populated with some data. A ToolTip object is then created, and its SetToolTip method is used to associate a tooltip message with each row of the grid. The message displays the type of food (fruit or vegetable) associated with each item. The package library for this feature is the .NET Framework Class Library.
public SetToolTip ( Control control, string caption ) : void | ||
control | Control | |
caption | string | |
return | void |