I have some validation code which should display the max / min of a control when a bad value is entered.
In my constructor I do this:
m_wndToolTip = gcnew ToolTip(this->components);
m_wndToolTip->AutoPopDelay = 5000;
m_wndToolTip->InitialDelay = 10;
m_wndToolTip->ReshowDelay = 250;
m_wndToolTip->ShowAlways = true;// Force the ToolTip text to be displayed whether or not the form is active.
This is my validation reflection code:
void MyGUI::IndicateValidationResult(Windows::Forms::Control^ control, bool isValid, String^ invalidReason)
{
// If the validation failed, make the background red. If not, turn it white.
if( isValid )
{
control->BackColor = Drawing::Color::White;
m_wndToolTip->Hide(control);
}
else
{
control->BackColor = Drawing::Color::LightCoral;
m_wndToolTip->Show(invalidReason, control);
}
}
...which is called from varous ValueChanged
methods in my text boxes. I've tried using show and also a combination of SetToolTip
and active = true
and nothing seems to work.
I've seen another question asking about tooltips and have tried setting a nearby label in the call to show but that doesn't fix it either. The tooltip is a member variable in my System::Windows::Forms::Form
derived form to stop it going out of scope.
Am I missing something obvious?