Skip to content

Winforms Customer Designer - DataGridView #8508

@dmanter

Description

@dmanter

.NET version

7.0

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Not tried - Worked in 4.7.2

Issue description

Hi Klaus,
I can’t find anywhere or anybody to help me with this problem. I had a programmer who wrote us a custom Form Designer using some old VS Designer Project from many years ago. Basically we allow user to design a form and then save it and the controls to xml. At runtime we read the xml make a dynamic user form with those controls. When they hit OK, it runs a stored procedure with SQL and the controls text entries are passed to the stored procedure as parameters. This allow things like a user can make a pricing update form with a simple textbox for price increase amount. The stored proc runs thru the price table and adds that. We have been using for many years. Just updating now off .Net 4 to .Net 7 to modernize our app. This Form Designer almost worked. The DateTimePicker and DataGridView get a no designer error. I’ve spent days tracking the code that fail and only get to this in the TypeDescriptor.
The line :type = Type.GetType(designerAttribute.DesignerTypeName); returns null for DTP and DGV but a designer for Labels, TextBox, RadioBUttons, CHeckBOx, etc.
Only null on DTP and DGV.
I can’t seem to get debug to step into the Type.GetType() so at a dead end.
I am stuck for days and at a loss what to do. DTP and DGV work in VS 2022 designer so there must be some way this can get at a designer for each.
Thanks Doug Manter, CTO Creative Information Systems, Inc.
[email protected]
Please help or advise. I wanted to leave under WinForms page but said comments closed.

public static IDesigner? CreateDesigner(IComponent component, Type designerBaseType)
{
    Type? type = null;
    IDesigner? result = null;
    AttributeCollection attributes = GetAttributes(component);
    for (int i = 0; i < attributes.Count; i++)
    {
        if (attributes[i] is DesignerAttribute designerAttribute)
        {
            Type? type2 = Type.GetType(designerAttribute.DesignerBaseTypeName);
            if (type2 != null && type2 == designerBaseType)
            {
                ISite? site = component.Site;
                bool flag = false;
                ITypeResolutionService? typeResolutionService = (ITypeResolutionService?)site?.GetService(typeof(ITypeResolutionService));
                if (typeResolutionService != null)
                {
                    flag = true;
                    type = typeResolutionService.GetType(designerAttribute.DesignerTypeName);
                }
                if (!flag)
                {
                    type = Type.GetType(designerAttribute.DesignerTypeName); <- RETURNS NULL for DateTimePicker and DataGridview.
                }
                if (type != null)
                {
                    break;
                }
            }
        }
    }
    if (type != null)
    {
        result = (IDesigner?)Activator.CreateInstance(type);
    }
    return result;
}

CustomFormDesignerIssue

Steps to reproduce

I could upload the whole project but unsure how.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions