Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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)

Posted (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 by Alexthemaster
  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...