Windows Develop Bookmark and Share   
 index > Windows Forms Designer > How to capture and save resources generated by CodeDomDesignerLoader in Custom Designer
 

How to capture and save resources generated by CodeDomDesignerLoader in Custom Designer

Finally got the custom designer working after reading this March's MSDN magazine article. now I can host the desinger surface, have the CodeCompileUnit generated from the CodeDomDesignerLoader and DesignSurface, and load the generated assembly correctly, but ONLY when there is no resource (like a background image) assigned for any of the controls on the DesignSurface. I can not figure out how to capture the serialized resource from the CodeDomDesignerLoader.

Included is the generated CS code, Look at the highlighted line below, the reference to the resource is generated, but how can I get the resources, so I can save it in a file, along with the generated CS file?

Thanks!

public class TestDashboard : System.Windows.Forms.UserControl

{

private System.Windows.Forms.Button button1;

public TestDashboard()

{

this.InitializeComponent();

}

private void InitializeComponent()

{

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TestDashboard));

this.button1 = new System.Windows.Forms.Button();

this.SuspendLayout();

//

// button1

//

this.button1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button1.BackgroundImage")));

this.button1.Location = new System.Drawing.Point(24, 62);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(396, 214);

this.button1.TabIndex = 0;

this.button1.Text = "button1";

this.button1.UseVisualStyleBackColor = true;

//

// TestDashboard

//

this.Controls.Add(this.button1);

this.Name = "TestDashboard";

this.Size = new System.Drawing.Size(456, 324);

this.ResumeLayout(false);

}

}

nb

zznb  Thursday, March 02, 2006 6:40 AM
You need to implement System.ComponentModel.Design.IResourceService if the sample does not already do this, as far as I know this area is not any different to .NET 1.1 so hopefully you should be able to get an example from somewhere. If not, the System.Resources.ResXResourceReader and System.Resources.ResXResourceWriter classes do most of the hard work for you, all you really have to do is get the resource data between the readers/writers and your file buffer.

Cheers,

Simon
simonl  Tuesday, March 21, 2006 3:18 PM

I have a same trouble.

I make my own designer and can’t get the resources from it.

Help please! Need any advice or sample.

 

MSDN Magazine > March 2006 > Create And Host Custom Designers With The .NET Framework 2.0

alex2000  Thursday, July 27, 2006 11:19 AM

You can use google to search for other answers

Custom Search

More Threads

• Chinese characters in Button.Text
• Merging 2 Excel Worksheets, Visual Studio
• Form Localization Issues Exception
• Reading appSettings from a custom ControlDesigner
• Reflection
• Connection string design-time editor
• How to make designer not to change anything in existing InitializeComponent method (designer code) ???
• Referenced Project controls not in Toolbox?
• master Detail relation in datagrid
• whats the last event fired from form before end user get controls?