Alexthemaster Posted December 17, 2008 Posted December 17, 2008 Hi, I've been looking for a while on internet to find an answer to this. the thing is: I want to access a Custom user control property from the parent form, to see if the login and password entered is true or false(if it exists), but i'm not very sure how to add a property or exactly how to proceed. here's what I have, I guess it's a start: [Description("Validate the account"), Category("Values"), DefaultValue(false), Browsable(true)] public bool Retvalue { } (This is not web) Quote
Alexthemaster Posted December 18, 2008 Author Posted December 18, 2008 (edited) Found the answer myself: // In the user control [Category("Configuration"), Description("This is the password"), Browsable(true)] public string Password { get; set; } or [Category("Configuration"), Description("value"), Browsable(true), DefaultValue(false)] public bool valacc { get; set; } And you can add events: //In the user control namespace controllib { public delegate void logindelg(object sender, EventArgs e); public partial class Logincontrol : UserControl { public event logindelg login_click; public event logindelg Cancel_click; [...] //In the main form private void login1_login_click(object sender, EventArgs e) { if (login1.valacc == true) { MessageBox.Show("Account activated"); } } Edited December 18, 2008 by Alexthemaster Quote
Administrators PlausiblyDamp Posted December 19, 2008 Administrators Posted December 19, 2008 The property itself would be a normal read only property (i.e. no set method). [Description("Validate the account"), Category("Values"), DefaultValue(false), Browsable(true)] public bool Retvalue { get {return }; } The Browsable(true) isonly required if you need this to appear in the property grid at design time - otherwise set it to false and in that case the Category and Description are also un-needed. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.