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);
}
}