문제

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...

도움이 되었습니까?

해결책

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top