The designer loader does not provide the root component, but does not identify the cause

Source: Internet
Author: User
Environment: Windows XP, VS 2005 SP1,. Net FX 2.0 SP1
Problem:
The system. componentmodel. Design. exceptioncollection type is thrown.
Designer Loading Program The root component is not provided, but the cause is not identified.

Description:
After the winform program is added, the datagridview program is added and the column replacement operation is performed (enumeration objects are dynamically bound to the column). This column replacement operation is performed in the backend CS Code Medium,
Not in designer. CS.
Solution:
Encapsulate the automatically generated datagridview columns and the generation method of the columns to be replaced in one method. For example: Code
Public Void initgridview ()
{
Datagridviewtextboxcolumn downloadtimedatagridviewtextboxcolumn = New maid ();
// Other Columns
Datagridviewcomboboxcolumn downloadtypedatagridviewtextboxcolumn = Dataloglist. createcomboboxlogtype ();
Datagridview1.columns. Clear ();
Datagridview1.autogeneratecolumns = False;
//  
// Downloadtimedatagridviewtextboxcolumn
//  
Downloadtimedatagridviewtextboxcolumn. datapropertyname = "Downloadtime ";
Downloadtimedatagridviewtextboxcolumn. headertext = "Delivery Time ";
Downloadtimedatagridviewtextboxcolumn. Name = "Downloadtimedatagridviewtextboxcolumn ";
Downloadtimedatagridviewtextboxcolumn. readonly = True;
//  
// Downloadtypedatagridviewtextboxcolumn
//  
Downloadtypedatagridviewtextboxcolumn. datapropertyname = "Downloadtype ";
Downloadtypedatagridviewtextboxcolumn. headertext = "Delivery type ";
This. datagridview1.columns. addrange (New datagridviewcolumn [] {
Downloadtimedatagridviewtextboxcolumn,
Deviceipdatagridviewtextboxcolumn,
Devicenamedatagridviewtextboxcolumn,
Inoutdatagridviewtextboxcolumn,
Workernamedatagridviewtextboxcolumn,
Idcarddatagridviewtextboxcolumn,
Workerfingeriddatagridviewtextboxcolumn,
Downloadtypedatagridviewtextboxcolumn,
Downloadresultdatagridviewtextboxcolumn,
Memodatagridviewtextboxcolumn });
}

This method is called in the constructor, for example: PublicShowwokerinfo ()
{
Initializecomponent ();
Initgridview ();
}

In this way, the above error disappears naturally, and the design is normal.

Attitude determines everything, technology changes life

Author: winzheng
Source: http://cnblogs.com/winzheng
This article is an original work. You are welcome to repost it, but you must keep this statement without the consent of the author. Article The original text link is clearly displayed on the page. Otherwise, the legal liability is retained.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.