Results 1 to 2 of 2

Thread: Creating custom controls?

  1. #1

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Creating custom controls?

    I've found need for a certain functionality several times thus far... namely, a check box that controls the enabled state of a text box. Granted, making the code for this isn't very difficult. But I'm wondering... what would I do to make a new control for it? Call it, say, CheckTextBox. It would hold many (but not all) properties of both check boxes and text boxes. Any starters?

    Please keep in mind that I've never tried to make my own controls before, and C# still isn't my primary language.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Creating custom controls?

    You would create a UserControl, add a CheckBox and a TextBox, then add properties as pass-throughs for the properties of the child controls, e.g.
    CSharp Code:
    1. public bool Checked
    2. {
    3.     get { return this.checkBox1.Checked; }
    4.     set { this.checkBox1.Checked = value }
    5. }
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width