c# - Image button on visual studio 2010 -


i trying create button image , no text [design] view on visual studio 2010. drag & dropped button, click image property, select png image resource file, property remain empty , button doesn't have image neither on [design] view or in compiled program.

i tried setting image on form.designer.cs file with:

    //      // button1     //      this.button1.location = new system.drawing.point(73, 11);     this.button1.name = "button1";     this.button1.size = new system.drawing.size(39, 34);     this.button1.tabindex = 10;     this.button1.usevisualstylebackcolor = true;     this.button1.image = properties.resources.close_project_img; 

and when go [design] view, error :

to prevent possible data loss before loading designer, following errors must resolved:   projectitem unavailable.       instances of error (1)    1.   show call stack    @ envdte.projectitem.get_filecount() @ microsoft.visualstudio.design.serialization.resxglobalobjectprovider.getfilenameforprojectitem(projectitem item) @ microsoft.visualstudio.design.serialization.resxglobalobject.buildtype() @ microsoft.visualstudio.design.serialization.resxglobalobject.getobjecttype() @ microsoft.visualstudio.shell.design.globaltype.get_objecttype() @ microsoft.visualstudio.shell.design.globalobject.gethashcode() @ system.collections.generic.objectequalitycomparer`1.gethashcode(t obj) @ system.collections.generic.dictionary`2.findentry(tkey key) @ microsoft.visualstudio.shell.design.globalobjectservice.getglobalobjects(type basetype) @ microsoft.visualstudio.design.serialization.codedom.aggregatetyperesolutionservice.gettypefromglobalobjects(string name, boolean throwonerror, boolean ignorecase) @ microsoft.visualstudio.design.serialization.codedom.aggregatetyperesolutionservice.gettype(string name, boolean throwonerror, boolean ignorecase) @ microsoft.visualstudio.design.serialization.codedom.aggregatetyperesolutionservice.gettype(string name) @ system.componentmodel.design.serialization.designerserializationmanager.getruntimetype(string typename) @ system.componentmodel.design.serialization.designerserializationmanager.gettype(string typename) @ system.componentmodel.design.serialization.designerserializationmanager.system.componentmodel.design.serialization.idesignerserializationmanager.gettype(string typename) @ system.componentmodel.design.serialization.codedomserializerbase.deserializeexpression(idesignerserializationmanager manager, string name, codeexpression expression) @ system.componentmodel.design.serialization.codedomserializerbase.deserializepropertyreferenceexpression(idesignerserializationmanager manager, codepropertyreferenceexpression propertyreferenceex, boolean reporterror) @ system.componentmodel.design.serialization.codedomserializerbase.deserializeexpression(idesignerserializationmanager manager, string name, codeexpression expression) @ system.componentmodel.design.serialization.codedomserializerbase.deserializepropertyassignstatement(idesignerserializationmanager manager, codeassignstatement statement, codepropertyreferenceexpression propertyreferenceex, boolean reporterror) @ system.componentmodel.design.serialization.codedomserializerbase.deserializeassignstatement(idesignerserializationmanager manager, codeassignstatement statement) @ system.componentmodel.design.serialization.codedomserializerbase.deserializestatement(idesignerserializationmanager manager, codestatement statement)    error    not find associated topic error. 

i can click "ignore , continue" , [design] view opens fine, button doesn't show image on view (it show in compiled program).

what doing wrong here?

you should not edit form.designer.cs directly because overwritten designer. designer runs code in form.designer.cs file when open designer. since code run vs2010, environment little diffrent

just test, try setting image property button_click event method instead, might image not found reason


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -