CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2008
    Posts
    14

    How to connect my pictureBox class to pictureBox element on F..

    Hi, Pros! I have a class

    class MyPicture: PictureBox
    ...

    And I have an element on Form pictureBox1. But the problem is that this
    element is connected to:

    private System.Windows.Forms.PictureBox pictureBox1;

    but I want it to be like this:

    private MyPicture pictureBox1. But the problem is that Microsoft warns
    that I can't edit in there:
    ...
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    ...
    this.pictureBox1 = new System.Windows.Forms.PictureBox();
    ...
    }

    ... as you can see I have no right to edit it like this:

    this.pictureBox1 = new MyPicture();


    How to overcome this legally?

  2. #2
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210

    Re: How to connect my pictureBox class to pictureBox element on F..

    I had similar issues, and changed the auto-generated code without problems.
    But if you can put MyPicture in the toolbox then drag & drop it on the form, this can be better and VS will handle it.
    Hesham A. Amin
    My blog , Articles


    <a rel=https://twitter.com/HeshamAmin" border="0" /> @HeshamAmin

  3. #3
    Join Date
    Apr 2008
    Posts
    14

    Re: How to connect my pictureBox class to pictureBox element on F..

    Quote Originally Posted by hspc
    I had similar issues, and changed the auto-generated code without problems.
    But if you can put MyPicture in the toolbox then drag & drop it on the form, this can be better and VS will handle it.
    But you can't get it on tool box... Tryed but failed to add it...

  4. #4
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210

    Re: How to connect my pictureBox class to pictureBox element on F..

    Quote Originally Posted by caabala
    But you can't get it on tool box... Tryed but failed to add it...
    Maybe if you try this method:
    The easy way to add controls to the VS2005 Toolbox
    Also try to make your custom control in a separate project (class library).
    Hesham A. Amin
    My blog , Articles


    <a rel=https://twitter.com/HeshamAmin" border="0" /> @HeshamAmin

  5. #5
    Join Date
    Apr 2008
    Posts
    14

    Re: How to connect my pictureBox class to pictureBox element on F..

    Quote Originally Posted by hspc
    Maybe if you try this method:
    The easy way to add controls to the VS2005 Toolbox
    Also try to make your custom control in a separate project (class library).
    Tnx, people. It is done. When you create a class and inherit it from pictureBox, then it appears in tool box!

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

Featured