Forum Discussion
SachsenHessi
Nov 21, 2022Copper Contributor
Visual Studio and problems with custom controls
Hello @all,
to first: sorry for my bad english !
And now to my problem:
I have for some time with VisualStudio 2019 the following problem:
In a project have custom controls.
For example, a custom button that inherited from System.Windows.Forms.
Public Class clsButton
Inherits System.Windows.Controls.Button
....
or
Public Class clsMasterForm
Inherits System.Windows.Forms.Form
...
Everything works, the "new" button works great, the new properties are active and can be used without any problems.
Suddenly, from one close of the project to the next open, VS2019 can't find the new controls.
Also from the toolbox (for WinForms) these controls have disappeared.
If I now exclude these controls from the project, and after a VS2019 restart, add them back to the project, everything works again. The controls are in the toolbox until the next time. Without that I can see any pattern/regularity.
(Environment: W10 current patch level, VS2019 current patch level, 64 GB memory, in an ADS).
Do any of you know what is happening here ? As I said it is rare and sporadic.
I also had this under VS2010 (on W7 PC).
Oh well, with VS2022 I could not test yet if it occurs there too.
Thanks a lot
SH
- JohnSmith11zCopper Contributor
I am sharing a code snippet that defines a custom class called CustomBtn which inherits from the Button class. It includes two properties - MaxImgNumber and MinImgNumber - that allow you to set the maximum and minimum number of images that can be used by the button.
If you face any issues while using this code, please refer to the accompanying details for further information. In case you are still unable to resolve the issue, please follow the instructions in the provided details to seek additional help. (Note: External links have been removed by the moderator for safety reasons.)
// This code defines a custom class called CustomBtn that inherits from the Button class.
public class CustomBtn : Button
{
// This property allows the maximum number of images that can be used by the button to be set.
[Browsable(true)]
public int MaxImgNumber { get; set; }// This property allows the minimum number of images that can be used by the button to be set.
public int MinImgNumber { get; set; }
} - JohnSmith11zCopper Contributor
Hi,
Hope this code helps:
// This code defines a custom class called CustomBtn that inherits from the Button class.
public class CustomBtn : Button
{
// This property allows the maximum number of images that can be used by the button to be set.
[Browsable(true)]
public int MaxImgNumber { get; set; }// This property allows the minimum number of images that can be used by the button to be set.
public int MinImgNumber { get; set; }
}// If using this code does not solve your issue, please refer to the provided details for further information.
If you still experience issues after implementing this code, please refer to the accompanying details for more information on how to resolve your issue. (external link removed by moderator) - johnsonsellenCopper Contributor
SachsenHessi I am sure it will help you, you may try this code
public class CustomBtn:Button
{
[Browsable(true)]
public int MaxImgNumber{get;set;}
public int MinImgNumber{get;set;}
}
after use this code or still remain the same issue then you can check this there is complete details about regarding your issue. (external link removed by moderator) - LanHuang
Microsoft
Hi SachsenHessi,
Thanks for posting your issue here.
However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang