This is a migrated thread and some comments may be shown as answers.

error message and help text don't show

6 Answers 87 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Tino
Top achievements
Rank 1
Tino asked on 24 Oct 2017, 10:41 PM

Unfortunately I'm using an older version of the winforms controls, but just in case someone can help..

I'm validating in the property view, but I can't get an error message to show. I even tried to set Description until I worked out the error message issue, but that doesn't show either. (I have the help panel showing).

I have a delegate doing the property validation, which returns me an error string if invalid. The string is being returned correctly. See below for my code; I've only changed a name or two.

private void OnValidating(object sender, PropertyValidatingEventArgs e)
{
    var item = e.Item as PropertyGridItem;
    if (item == null) return;
 
    if (_validateProperty != null)
    {
        var item = GetViewModelItem(sender);
        var error = "";
        var valid = _validateProperty(item, e.Item.Name, e.NewValue as string, out error);
        if (!valid)
        {
            // TODO: error message not showing
            item.ErrorMessage = error;
        }
        e.Cancel = !valid;
    }
}

6 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 25 Oct 2017, 08:42 AM
Hi Tino,

Could you specify the exact version number that you are using?

Please note that the description is displayed in the help panel. The error message is shown when you are hovering the red exclamation mark. I have attached a small project that shows how this works.

I am looking forward to your reply.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Tino
Top achievements
Rank 1
answered on 05 Dec 2017, 09:11 PM

Seems to be 2017.3.912.40

0
Dimitar
Telerik team
answered on 06 Dec 2017, 11:11 AM
Hi Tino,

I have tested it with this version and it appears to work correctly on my side (see attached video). Could you please let me know what I need to change in the test project in order to reproduce the undesired behavior? Or perhaps you want to achieve something else?

I am looking forward to your reply.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Tino
Top achievements
Rank 1
answered on 12 Dec 2017, 01:24 AM

I found something that fixed it. I had ShowItemToolTips set to False on my PropertyGrid control. I set it to True and can see the message.

However, I don't get the message appearing in the help area, it appears as a tooltip, like in the documentation. This is actually my preference, so that's fine, but I'm not sure why yours is different. The only problem is that the user must hover over a very small area, the "!" character, to see the message.

I also tried a fresh project similar to yours, and I still get the message as a tooltip.

A sample project would've been good too.

0
Dimitar
Telerik team
answered on 12 Dec 2017, 09:32 AM
Hi Tino,

This is the default behavior and the error message is displayed in the tooltip. The help panel displays the string from the description attribute. You can use the following approach in order to increase the area where the tooltip appears:
private void RadPropertyGrid1_ToolTipTextNeeded(object sender, Telerik.WinControls.ToolTipTextNeededEventArgs e)
{
    var item = sender as PropertyGridItemElement;
 
    if (item != null)
    {
        var data = item.Data as PropertyGridItem;
        if (data.ErrorMessage != null)
        {
             e.ToolTipText = data.ErrorMessage;
        }
    }
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Tino
Top achievements
Rank 1
answered on 12 Dec 2017, 08:53 PM
You're right, I got my wires crossed there. Thanks for the help and I think you've answered everything now.
Tags
PropertyGrid
Asked by
Tino
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Tino
Top achievements
Rank 1
Share this question
or