Results 1 to 5 of 5

Thread: Custom Controls - Designer

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2012
    Posts
    313

    Question Custom Controls - Designer

    Hi,

    If I create a custom control, let's say a Panel. If I have various controls within this Panel, more often than not after running the program in my designer view that Panel goes blank and the controls aren't visible.

    I have to close the designer and open it again and everything is displayed again.

    Is there a way to prevent this happening?

    Thank you.

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

    Re: Custom Controls - Designer

    Please provide the simplest example you can to demonstrate the actual problem. Your question really doesn't make all that much sense as it is because a Panel is not a custom control. It may be that you should be creating a user control, which is a specific thing, but it's hard to tell because your question is too vague.
    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2012
    Posts
    313

    Question Re: Custom Controls - Designer

    Apologies, I have created a Custom Control "CustomPanel" that Inherits the standard Panel Control.

    vb Code:
    1. Public Class CustomPanel
    2.     Inherits System.Windows.Forms.Panel
    3.  
    4.     Protected Overrides Function ScrollToControl(ByVal activeControl As System.Windows.Forms.Control) As System.Drawing.Point
    5.         Return Me.AutoScrollPosition
    6.     End Function
    7. End Class

    In the form designer for the Form that I use the CustomPanel on I have several other Controls e.g. TextBox, ComboBox etc. placed within the CustomPanel. They all appear fine, but more often than not after I've clicked "Start" to test my application the Panel is blank. I can select the contained Controls from the drop down in Properties, but it's only after I close the designer and open it fresh that they all appear as they should. Also if I do use the Properties drop down to the select a Control, the outline highlight for the selected Control shows way off position. I will get some screenshots when I'm back home.

    Thank you.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,320

    Re: Custom Controls - Designer

    I'll be interested to hear whether anybody has a good answer for this one. It sounds like a bug in the designer, to me. VS2022 is pretty good, but it is not without flaws. I've seen cases where the designer failed to render properly, and they may or may not be related to your specific case. Just yesterday, I was looking at a simple WPF page (form, just not called a form), and I couldn't see it at all. In the WPF designer, sometimes it starts out zoomed way out and scrolled weirdly, such that the form is there, it's just shrunk small and off the bottom of the screen, but not in this case. I couldn't find that form anywhere, so I closed the designer and re-opened it, and all was well. That sounds suspiciously like what you are describing, it's just that I was in WPF.
    My usual boring signature: Nothing

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,662

    Re: Custom Controls - Designer

    Quote Originally Posted by Shaggy Hiker View Post
    I'll be interested to hear whether anybody has a good answer for this one. It sounds like a bug in the designer, to me. VS2022 is pretty good, but it is not without flaws.
    The designer was also rebuilt from scratch for .NET Core, so it contains some bugs that do not exist in the .NET Framework designer. If this is a .NET Core app (including .NET 5 and later) then I would suggest testing the same thing in a .NET Framework project to see whether the same thing happens. If it works as expected in .NET Framework but not .NET Core then it is almost certainly a designer bug and you can report it to Microsoft. They are actually adding new features to WinForms in .NET 9 so they are more likely address such issues now than they have been for a while.
    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