Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > handle my tool tips
 

handle my tool tips

hi all

i have datagried event work inside a thread,this event make tooltips from datagrid cell and show on to user by myself but when the text in cell is long like:
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
make my application in hang mode how can i handle my tooltips?

private void dataGridView1_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
try
{
toolTip1 = new ToolTip();


string stlong = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
toolTip1.Show(stlong, dataGridView1, dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).X + 45, dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Y + 25, 50000);


}
catch(Exception err)
{
ClLogTrans.WriteMessage("DTGRMCENTR: " + err.Message.ToString());
}
}
Thanks Motevallizadeh
motevallizadeh  Tuesday, July 28, 2009 6:20 AM
oooops it's a win application
no i did not get exception from it? just when i traced it it com on this line and application goto waiting or sleep mode

without using thread it works goooooooooooood with each size of test

toolTip1.Show(stlong, dataGridView1, dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).X + 45, dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Y + 25, 50000);

Thanks Motevallizadeh
motevallizadeh  Tuesday, July 28, 2009 7:32 AM
Motevallizadeh,

The problem may be occuring because you are making the page do a postback each time the mouse enters a cell (at least this is what the code suggests, I haven't tested it).

Instead of trying to show your tool tips this way another method you can try is to add them to your GridView columns using the ToolTip property of one of your controls. Just bind whatever data you want from your datasource to this ToolTip and it should work ok.

For example:

<asp:GridView ID="GridView runat="server" DataSourceId="YourDataSource">
<span style="white-space:pre">	</span><Columns>
<span style="white-space:pre">		</span><asp:TemplateField>
 <span style="white-space:pre">			</span><asp:Label ID="Label1" runat="server" ToolTip='<%# Bind("ToolTipText") %>' Text='<%# Bind("Text") %>'></asp:Label>
<span style="white-space:pre">		</span></asp:TemplateField>
<span style="white-space:pre">	</span></Columns>
</asp:GridView>
In the above example you can see that the TemplateField contains a label (it could be any control that supports the ToolTip property) and it is bound to a field in the datasource.

This works perfectly for me even with very long text. You may have to rework the way you are doing things but...

Ben.

P.S. also make sure you use the "Insert Code Block" button (next to the HTML one) in the editor's toolbar to make it easy to read.
Ben Harnett  Tuesday, July 28, 2009 6:42 AM
oooops it's a win application
no i did not get exception from it? just when i traced it it com on this line and application goto waiting or sleep mode

without using thread it works goooooooooooood with each size of test

toolTip1.Show(stlong, dataGridView1, dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).X + 45, dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Y + 25, 50000);

Thanks Motevallizadeh
motevallizadeh  Tuesday, July 28, 2009 7:32 AM
Sorry my bad.
Ben Harnett  Tuesday, July 28, 2009 11:40 PM

You can use google to search for other answers

Custom Search

More Threads

• How can I set a value in a cell of the DataGridView that contains a DataGridViewComboBoxColumn?
• DataGridViewCellStyle
• Collection of business objects implementing IEditableObject and "ReadOnly" DataGrid
• DataGridViewCheckBoxColumn, DataSets and Read/Write XML Methods
• Data Grid View Row State not accurate
• How to save DataGridView rows to database in easiest way
• ColumnChanged event not fired when current column value is changed
• How to get extended tableadapter partial class code to run?
• DataBinding with the usercontrol made by combobox
• Help: DGV Combobox settings