Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / February 2005

Tip: Looking for answers? Try searching our database.

Getting a CommonControl to refresh

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Curtis - 17 Feb 2005 16:53 GMT
I found this after I posted this question in the .NET group and it may have
been better here.

I am having some trouble getting my common compenent to be able to refresh
and I am hoping someone will be able to tell me what I am missing.  To simply
things I have created a solution with a class inherting a textbox and I have
added a property called buttontype.  When I set the button type it changes
some properties of the textbox like the textproperty.  When I set it to
ButtonType.Add the text on the button switches to say "Add".  

I then have another solution with a refrence to the above dll and when I add
my control on and set my button type it switches the text.  If I change my
original solution to change the text to "Add 2" when the button type is set
to Add, my second solution will not pick it up till I go and change the
button type property to something else and then back again.  If I look at the
Windows generated code for my second solution,  I see a line for setting the
button type and a line that is setting the text property as well.   I am
thinking is causing me my problem.  If I comment out the line that changes
the text and run the application it will pick up whatever changes I make in
my oringal solution.   How do I get .NET to stop putting the line that
switches the text in the windows generated code when I am designing my form
or once I make a change to my original dll how do I get my second solution to
pick that up.  
joeycalisay - 18 Feb 2005 03:27 GMT
Do you really want its Text property to change when your custom property is
changed?  What will happen if a user changes the Text property of the
control after setting the custom property (ButtonType).  If you want the
Text to really depend on the custom property, I suggest you override the
Text property of your custom TextBox control and hide it from the
propertygrid (using BrowsableAttribute) and serialization
(DesignerSerializationAttribute).  Then in the Set method of your proeprty,
you set base.Text depending on the value of the ButtonType.

public enum ButtonType

{

           Add,

           Cancel

}

public class CustomButton : Button

{

           private ButtonType myProperty = ButtonType.Add;

           [DefaultValue(ButtonType.Add),

           Category("Custom Properties")]

           public ButtonType MyProperty

           {

                       set

                       {

                                   this.myProperty = value;

                                   base.Text = value.ToString();

                       }

                       get

                       {

                                   return this.myProperty;

                       }

           }

           [Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

           public override string Text

           {

                       get

                       {

                                   return base.Text;

                       }

                       set

                       {

                                   base.Text = value;

                       }

           }

           public CustomButton()

           {

                       base.Text = "Add";

           }

}

Signature

Joey Calisay
http://spaces.msn.com/members/joeycalisay/

> I found this after I posted this question in the .NET group and it may have
> been better here.
[quoted text clipped - 19 lines]
> or once I make a change to my original dll how do I get my second solution to
> pick that up.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.