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.