SuperTooltip for WinForms
カスタム処理
SuperTooltipの操作 > カスタム処理

The SuperToolTip supports custom processing by displaying supertooltip for MS DataGridView's cell or ListView's item instead of showing the cell's or item's own tooltip text. For this, you can use UseCellTips property of the C1SuperTooltipBase class, which indicates whether the tooltip should display ToolTip text of Microsoft's DataGridView cells or Microsoft's ListView items.

To display supertooltip instead of cell's tooltip text in MS DataGridView, you need to assign a supertooltip to the DataGridView using the SetToolTip method, enable the supertooltip by setting the UseCellTips property to True, and disable DataGridView's cell tooltip by setting ShowCellTooltips property to false as showcased in the following code:

C#
コードのコピー
private void Form1_Load(object sender, EventArgs e)
{
    //デフォルトのツールチップ
    dataGridView1.Rows[0].Cells[0].ToolTipText = "Cell (1,1) tooltip";
    //太字
    dataGridView1.Rows[0].Cells[1].ToolTipText = "<b>Cell (1,2) tooltip</b>";
    //htmlでスタイル設定
    dataGridView1.Rows[0].Cells[2].ToolTipText = "<span style=\"color:#0000ff;\">Cell (1,3) tooltip</span>";          
    dataGridView1.Rows[0].Cells[3].ToolTipText = "<span style=\"color:#ff0000;font-family:Helvetica;font-size:16;\"><b>Cell (1,4) tooltip</b></span>";
 
    //行と列のヘッダ用のツールチップ
    dataGridView1.Columns[0].ToolTipText = "ColumnTip";
    dataGridView1.Columns[0].HeaderCell.ToolTipText = "Col1 Header ToolTip";
    dataGridView1.Columns[1].HeaderCell.ToolTipText = "<span style=\"color:#0000ff;\">Col2 Header ToolTip</span>";
    dataGridView1.Columns[2].HeaderCell.ToolTipText = "<b>Col3 Header ToolTip</b>";
    dataGridView1.Rows[0].HeaderCell.ToolTipText = "Row Header ToolTip";
    dataGridView1.TopLeftHeaderCell.ToolTipText = "Topleft ToolTip";
    // SuperTooltipを特定のコントロール(ここではDataGridView)に割り当てます
    c1SuperTooltip1.SetToolTip(dataGridView1, "<table><tr>" +
    "<th>DataGridView SuperTooltip</th>" + "</tr></table>");
    //dataGridView1に空のSuperTooltipを設定することもできます-この場合、セルのツールチップのみが表示されます
    //c1SuperTooltip1.SetToolTip(dataGridView1, "");
   
    // DataGridViewセルのsupertooltipの表示を有効にします
    c1SuperTooltip1.UseCellTips = true;
    //MSDataGridViewのセルのヒントの表示を無効にします
    dataGridView1.ShowCellToolTips = false;
}

To enable different text for different cells in the SuperTooltip, the user should set the standard ToolTipText for DataGridView cells. User can also use html tags in ToolTipText as these will be processed by the SuperTooltip.

You can also show the MS DataGridView ColumnHeaderCell's, RowHeaderCell's or TopLeftCell's tooltips as C1SuperTooltip if these are set.