protected void PopulateReadingsGrid()
{
if (sd == null || sd.ReadingsCount == 0) return;
pb.Value1 = 0;
pb.Maximum = sd.ReadingsCount;
ToolTip toolTip1 = new ToolTip();
DataTable dt = new DataTable();
DataColumn dcIndex = new DataColumn("No");
DataColumn dcDate = new DataColumn("Date");
DataColumn dcTime = new DataColumn("Time");
DataColumn dcUnComp = new DataColumn("UnCompensated Height");
DataColumn dcCompHeight = new DataColumn(sd.isBarometric ? "Pressure" : "Compensated Height");
DataColumn dcWaterDepthBelowDatum = new DataColumn("Depth of Water Below Datum");
DataColumn dcTemperature = new DataColumn("Temperature");
dt.Columns.Add(dcIndex);
dt.Columns.Add(dcDate);
dt.Columns.Add(dcTime);
dt.Columns.Add(dcUnComp);
dt.Columns.Add(dcCompHeight);
dt.Columns.Add(dcWaterDepthBelowDatum);
dt.Columns.Add(dcTemperature);
}
That's part of my code up there. My question is how to add tool tip text on title of my datacolumn? For example, adding tool tip text on "No" or "Date"...?
private void dt_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.ColumnIndex == -1)
{
// get text
string msg = (sender as DataGridView).Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
// Get mouse position relative to the grid
var relativeMousePosition = dt.PointToClient(Cursor.Position);
// Show the tooltip
this.toolTip1.Show(msg, dt, relativeMousePosition);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.