Question

We are using Infragistics' UltraCombo in a WinForms app.

Sometimes the displayed text (in the combo box itself, i.e. when it's not expanded) is too long to be completely shown.

Is there any way to only provide tooltips when this text is cut off and not to show the tooltip when the displayed text completely fits into the UltraCombo combobox?

Many thanks...

Was it helpful?

Solution

The only way I am aware is to manually determine if the current text is too wide.

Add a tooltip to the form. Then handle the TextChanging event on your combo box.

private void ultraCombo1_TextChanged( object sender, EventArgs e )
{
    var textWidth = TextRenderer.MeasureText( ultraCombo1.Text, ultraCombo1.Font ).Width;
    var textBoxWidth = ultraCombo1.ClientRectangle.Width - SystemInformation.VerticalScrollBarWidth;
    if ( textWidth < textBoxWidth )
        toolTip1.SetToolTip( ultraCombo1, "" );
    else
        toolTip1.SetToolTip( ultraCombo1, ultraCombo1.Text);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top