तुम हमेशा एक StatusStrip
स्थिति पट्टी से स्पष्टीकरण है और CellMouseEnter
और CellMouseLeave
घटनाओं सेट का उपयोग कर और (क्रमशः) निकाल सकते हैं।
private void dgvCellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
statusStrip1.Text = (sender as DataGridView)[e.ColumnIndex, e.RowIndex].ToolTipText;
}
private void dgvCellMouseLeave(object sender, DataGridViewCellEventArgs e)
{
statusStrip1.Text = "";
}
एक अतिरिक्त सुविधा के रूप में, आप दिखा सकते हैं कि सेल में एक छोटा चिह्न दिखाकर "अतिरिक्त" जानकारी है जैसे एक्सेल करता है। यहाँ है कि मैं बिल्कुल वही चीज़ करते करने के लिए उपयोग कोड का एक छोटा स्निपेट है:
private void dgvCellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex != -1) && (e.RowIndex != -1)
{
DataGridViewCell dgvCell = (sender as DataGridView)[e.ColumnIndex, e.RowIndex];
Pen greenPen = new Pen(Color.Green, 2);
Boolean hasTooltip = !dgvCell.ToolTipText.Equals("");
Boolean hasCompleted = (dgvCell.Tag as CellInfo).complete; // CellInfo is a custom class
if (hasTooltip) && (hasCompleted)
{
e.Handled = true;
e.Paint(e.ClipBounds, e.PaintParts);
e.Graphics.DrawRectangle(Pens.Blue, e.CellBounds.Left + 5, e.CellBounds.Top + 2, e.CellBounds.Width - 12, e.CellBounds.Height - 6);
e.Graphics.DrawRectangle(greenPen, e.CellBounds.Left + 1, e.CellBounds.Top + 1, e.CellBounds.Width - 3, e.CellBounds.Height - 3);
}
else if (hasTooltip)
{
e.Handled = true;
e.Paint(e.ClipBounds, e.PaintParts);
e.Graphics.DrawRectangle(Pens.Blue, e.CellBounds.Left, e.CellBounds.Top, e.CellBounds.Width - 2, e.CellBounds.Height - 2);
}
else if (hasCompleted)
{
e.Handled = true;
e.Paint(e.ClipBounds, e.PaintParts);
e.Graphics.DrawRectangle(greenPen, e.CellBounds.Left + 1, e.CellBounds.Top + 1, e.CellBounds.Width - 3, e.CellBounds.Height - 3);
}
}
}
इस कोड को सेल यदि hasTooltip
सच है, एक हरे रंग की सीमा है अगर hasCompleted
सच है, और दोनों सीमाओं के चारों ओर एक नीले बॉर्डर के ड्रॉ (साथ अंदर हरा एक) यदि दोनों सच हैं।
क्या सेल दिखाएगा कि टूलटिप उपलब्ध है? – CJ7
नहीं, यह नहीं होगा, हालांकि आप सेल पर एक CssClass जोड़कर भी ऐसा कर सकते हैं। यानी CssClass = "है-टूलटिप"। फिर अपनी रचनात्मकता का उपयोग करें और अधिक जानकारी के संकेत देने के लिए थोड़ा "i" आइकन जोड़ें। – Marko
@ मार्को: क्या यह मूल रूप से एक स्मार्ट टैग नहीं है? – CJ7