.NET Framework Class Library DataGridViewCell..::.ToolTipText Property Gets or sets the ToolTip text associated with this cell.
Namespace:
System.Windows.Forms
Assembly:
System.Windows.Forms (in System.Windows.Forms.dll)

Syntax
<BrowsableAttribute(False)> _
Public Property ToolTipText As String
Get
Set
[BrowsableAttribute(false)]
public string ToolTipText { get; set; }
[BrowsableAttribute(false)]
public:
property String^ ToolTipText {
String^ get ();
void set (String^ value);
}
[<BrowsableAttribute(false)>]
member ToolTipText : string with get, set

Remarks

Examples
The following code example shows how to set the ToolTipText property within an event handler for the CellFormatting event. This example is part of a larger code example provided in How to: Add ToolTips to Individual Cells in a Windows Forms DataGridView Control.
' Sets the ToolTip text for cells in the Rating column.
Sub dataGridView1_CellFormatting(ByVal sender As Object, _
ByVal e As DataGridViewCellFormattingEventArgs) _
Handles dataGridView1.CellFormatting
If e.ColumnIndex = Me.dataGridView1.Columns("Rating").Index _
AndAlso (e.Value IsNot Nothing) Then
With Me.dataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex)
If e.Value.Equals("*") Then
.ToolTipText = "very bad"
ElseIf e.Value.Equals("**") Then
.ToolTipText = "bad"
ElseIf e.Value.Equals("***") Then
.ToolTipText = "good"
ElseIf e.Value.Equals("****") Then
.ToolTipText = "very good"
End If
End With
End If
End Sub 'dataGridView1_CellFormatting
// Sets the ToolTip text for cells in the Rating column.
void dataGridView1_CellFormatting(object sender,
DataGridViewCellFormattingEventArgs e)
{
if ( (e.ColumnIndex == this.dataGridView1.Columns["Rating"].Index)
&& e.Value != null )
{
DataGridViewCell cell =
this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (e.Value.Equals("*"))
{
cell.ToolTipText = "very bad";
}
else if (e.Value.Equals("**"))
{
cell.ToolTipText = "bad";
}
else if (e.Value.Equals("***"))
{
cell.ToolTipText = "good";
}
else if (e.Value.Equals("****"))
{
cell.ToolTipText = "very good";
}
}
}
// Sets the ToolTip text for cells in the Rating column.
void dataGridView1_CellFormatting(Object^ /*sender*/,
DataGridViewCellFormattingEventArgs^ e)
{
if ( (e->ColumnIndex == this->dataGridView1->Columns["Rating"]->Index)
&& e->Value != nullptr )
{
DataGridViewCell^ cell =
this->dataGridView1->Rows[e->RowIndex]->Cells[e->ColumnIndex];
if (e->Value->Equals("*"))
{
cell->ToolTipText = "very bad";
}
else if (e->Value->Equals("**"))
{
cell->ToolTipText = "bad";
}
else if (e->Value->Equals("***"))
{
cell->ToolTipText = "good";
}
else if (e->Value->Equals("****"))
{
cell->ToolTipText = "very good";
}
}
}

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

See Also
|
Biblioteca de clases de .NET Framework DataGridViewCell..::.ToolTipText (Propiedad) Obtiene o establece el texto de información sobre herramientas asociado a esta celda.
Espacio de nombres:
System.Windows.Forms
Ensamblado:
System.Windows.Forms (en System.Windows.Forms.dll)

Sintaxis
<BrowsableAttribute(False)> _
Public Property ToolTipText As String
Get
Set
[BrowsableAttribute(false)]
public string ToolTipText { get; set; }
[BrowsableAttribute(false)]
public:
property String^ ToolTipText {
String^ get ();
void set (String^ value);
}
[<BrowsableAttribute(false)>]
member ToolTipText : string with get, set

Comentarios
El valor de esta propiedad se muestra como información sobre herramientas de la celda cuando el puntero del mouse está sobre la celda y el valor de la propiedad es distinto de Empty. Si el valor de esta propiedad es Empty, la celda muestra una información sobre herramientas que contiene el valor de la celda, si el valor está truncado en la presentación de la celda; de lo contrario, la celda no mostrará información sobre herramientas. También puede evitar la presentación de información sobre herramientas estableciendo la propiedad DataGridView..::.ShowCellToolTips en false. Cuando se ha establecido la propiedad DataSource del control DataGridView, o si su propiedad VirtualMode es true, la obtención del valor de la propiedad ToolTipText provoca el evento CellToolTipTextNeeded del control y devuelve el valor de la propiedad DataGridViewCellToolTipTextNeededEventArgs..::.ToolTipText que especifique el controlador de eventos. Si no hay controladores para el evento, la obtención del valor de la propiedad ToolTipText devuelve el valor especificado anteriormente o su valor predeterminado, Empty. Resulta muy útil controlar el evento CellToolTipTextNeeded cuando se trabaja con grandes volúmenes de datos para evitar las reducciones del rendimiento al establecer el valor de la propiedad ToolTipText para varias celdas. Para obtener más información, vea Procedimientos recomendados para ajustar la escala del control DataGridView en formularios Windows Forms. Si se cambia esta propiedad, se provoca el evento CellToolTipTextChanged en el control DataGridView propietario, si existe.

Ejemplos
En el ejemplo de código siguiente se muestra cómo establecer la propiedad ToolTipText en el controlador de eventos para el evento CellFormatting. Este ejemplo forma parte de un ejemplo de código más extenso que se proporciona en Cómo: Agregar información sobre herramientas a celdas individuales en un control DataGridView de formularios Windows Forms.
' Sets the ToolTip text for cells in the Rating column.
Sub dataGridView1_CellFormatting(ByVal sender As Object, _
ByVal e As DataGridViewCellFormattingEventArgs) _
Handles dataGridView1.CellFormatting
If e.ColumnIndex = Me.dataGridView1.Columns("Rating").Index _
AndAlso (e.Value IsNot Nothing) Then
With Me.dataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex)
If e.Value.Equals("*") Then
.ToolTipText = "very bad"
ElseIf e.Value.Equals("**") Then
.ToolTipText = "bad"
ElseIf e.Value.Equals("***") Then
.ToolTipText = "good"
ElseIf e.Value.Equals("****") Then
.ToolTipText = "very good"
End If
End With
End If
End Sub 'dataGridView1_CellFormatting
// Sets the ToolTip text for cells in the Rating column.
void dataGridView1_CellFormatting(object sender,
DataGridViewCellFormattingEventArgs e)
{
if ( (e.ColumnIndex == this.dataGridView1.Columns["Rating"].Index)
&& e.Value != null )
{
DataGridViewCell cell =
this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (e.Value.Equals("*"))
{
cell.ToolTipText = "very bad";
}
else if (e.Value.Equals("**"))
{
cell.ToolTipText = "bad";
}
else if (e.Value.Equals("***"))
{
cell.ToolTipText = "good";
}
else if (e.Value.Equals("****"))
{
cell.ToolTipText = "very good";
}
}
}
// Sets the ToolTip text for cells in the Rating column.
void dataGridView1_CellFormatting(Object^ /*sender*/,
DataGridViewCellFormattingEventArgs^ e)
{
if ( (e->ColumnIndex == this->dataGridView1->Columns["Rating"]->Index)
&& e->Value != nullptr )
{
DataGridViewCell^ cell =
this->dataGridView1->Rows[e->RowIndex]->Cells[e->ColumnIndex];
if (e->Value->Equals("*"))
{
cell->ToolTipText = "very bad";
}
else if (e->Value->Equals("**"))
{
cell->ToolTipText = "bad";
}
else if (e->Value->Equals("***"))
{
cell->ToolTipText = "good";
}
else if (e->Value->Equals("****"))
{
cell->ToolTipText = "very good";
}
}
}

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.0 .NET Framework Client ProfileCompatible con: 4, 3.5 SP1

Plataformas
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Vea también
|