469,626 Members | 1,760 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

ToolTip over a DataGridView row?

I have a standard VC# 2005 DataGridView showing a group of records
coming from a table. Currently I have a CellMouseDoubleClick event
popping up a MessageBox which pulls a timestamp of the transaction
from a related table based on the row in the DataGridView that the
double click was registered against. I didn't want to add the extra
column with this timestamp info into the DataGridView since it's not
always needed by the enduser.

Rather than this double click mechanism I would like the ability to
create a mouse over event that would present this timestamp in a
bubble to the enduser. If they hover the mouse over a cell then that
row is fed into the method I have that presents the timestamp.
Checking out the ToolTip control it appears as if I can just define
the text to be presented if the enduser hovers their mouse over the
column headings. Not the cell contents themselves.

Am I missing something here? Even a basic example would be
appreciated, since I'm not looking to define the text explicitly in a
control property. I need to programmatically define it by passing the
DataGridView row's values into a method.

Thanks!

Apr 20 '07 #1
4 39792
On Apr 20, 9:19 am, gregarican <greg.kuj...@gmail.comwrote:
I have a standard VC# 2005 DataGridView showing a group of records
coming from a table. Currently I have a CellMouseDoubleClick event
popping up a MessageBox which pulls a timestamp of the transaction
from a related table based on the row in the DataGridView that the
double click was registered against. I didn't want to add the extra
column with this timestamp info into the DataGridView since it's not
always needed by the enduser.

Rather than this double click mechanism I would like the ability to
create a mouse over event that would present this timestamp in a
bubble to the enduser. If they hover the mouse over a cell then that
row is fed into the method I have that presents the timestamp.
Checking out the ToolTip control it appears as if I can just define
the text to be presented if the enduser hovers their mouse over the
column headings. Not the cell contents themselves.

Am I missing something here? Even a basic example would be
appreciated, since I'm not looking to define the text explicitly in a
control property. I need to programmatically define it by passing the
DataGridView row's values into a method.

Thanks!
Please disregard. I googled some more through the group postings and
found my answer!

Apr 20 '07 #2
Care to show your link to the answer so others might benefit? =)
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"gregarican" <gr*********@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
On Apr 20, 9:19 am, gregarican <greg.kuj...@gmail.comwrote:
>I have a standard VC# 2005 DataGridView showing a group of records
coming from a table. Currently I have a CellMouseDoubleClick event
popping up a MessageBox which pulls a timestamp of the transaction
from a related table based on the row in the DataGridView that the
double click was registered against. I didn't want to add the extra
column with this timestamp info into the DataGridView since it's not
always needed by the enduser.

Rather than this double click mechanism I would like the ability to
create a mouse over event that would present this timestamp in a
bubble to the enduser. If they hover the mouse over a cell then that
row is fed into the method I have that presents the timestamp.
Checking out the ToolTip control it appears as if I can just define
the text to be presented if the enduser hovers their mouse over the
column headings. Not the cell contents themselves.

Am I missing something here? Even a basic example would be
appreciated, since I'm not looking to define the text explicitly in a
control property. I need to programmatically define it by passing the
DataGridView row's values into a method.

Thanks!

Please disregard. I googled some more through the group postings and
found my answer!

Apr 20 '07 #3
For a Windows Forms DataGridView, you can handle the
dataGridView1.CellToolTipTextNeeded event and dynamically provide the
tip text there.

dataGridView1.CellToolTipTextNeeded += new
DataGridViewCellToolTipTextNeededEventHandler(data GridView1_CellToolTipTextNeeded);
void dataGridView1_CellToolTipTextNeeded(object sender,
DataGridViewCellToolTipTextNeededEventArgs e)
{
e.ToolTipText = string.Format("tip for row {0}, col {1}",
e.RowIndex, e.ColumnIndex);
}

========================
Clay Burch
Syncfusion, Inc.

Apr 20 '07 #4
On Apr 20, 11:18 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Care to show your link to the answer so others might benefit? =)

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"gregarican" <greg.kuj...@gmail.comwrote in message

news:11**********************@n76g2000hsh.googlegr oups.com...
On Apr 20, 9:19 am, gregarican <greg.kuj...@gmail.comwrote:
I have a standard VC# 2005 DataGridView showing a group of records
coming from a table. Currently I have a CellMouseDoubleClick event
popping up a MessageBox which pulls a timestamp of the transaction
from a related table based on the row in the DataGridView that the
double click was registered against. I didn't want to add the extra
column with this timestamp info into the DataGridView since it's not
always needed by the enduser.
Rather than this double click mechanism I would like the ability to
create a mouse over event that would present this timestamp in a
bubble to the enduser. If they hover the mouse over a cell then that
row is fed into the method I have that presents the timestamp.
Checking out the ToolTip control it appears as if I can just define
the text to be presented if the enduser hovers their mouse over the
column headings. Not the cell contents themselves.
Am I missing something here? Even a basic example would be
appreciated, since I'm not looking to define the text explicitly in a
control property. I need to programmatically define it by passing the
DataGridView row's values into a method.
Thanks!
Please disregard. I googled some more through the group postings and
found my answer!- Hide quoted text -

- Show quoted text -
What I did was set the ShowCellToolTips DataGridView property to False
in the design view. By default it's set to True. Then I went in and
defined the CellMouseEnter event for the DataGridView. Here's a
snippet, where dgv_Lookup is a DataGridView instance, and ttLookup is
a ToolTip instance:

dgvLookup_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
// Ignore any mouse hovers other than those at column 7.
Also ignore any invalid RowIndex values.
if (e.RowIndex != -1 && e.ColumnIndex == 7)
{
DataTable showTable = new DataTable();
DataRow showRow;
showRow = showTable.NewRow();
dsTableAdapters.taTrxTableAdapter taTrxTable = new
dsTableAdapters.taTrxTableAdapter();
showTable =
taTrxTable.GetDataById(this.dgvLookup.Rows[e.RowIndex].Cells[0].Value.ToString());

// Just fetch the first row of the result set.
showRow = showTable.Rows[0];
this.dgvLookup.CurrentCell.ToolTipText =
showRow["loggedTime"].ToString();

this.ttLookup.Show(showRow["loggedTime"].ToString(), this.dgvLookup);
}
}

Apr 20 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by soum | last post: by
reply views Thread by giddy | last post: by
3 posts views Thread by Eran.Yasso | last post: by
3 posts views Thread by Richard Lewis Haggard | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.