Hi all
Are there any VB.NET Winforms gurus around.
I am struggling with custom controls in Winforms. So when I start a new project in Visfox I create custom VCXs for the different forms and form controls. I then use these custom controls throughout the project.
I can create an inherited form with the layout I need but when I use this form in the project all the base controls are locked which I think is something to do with "Friend" but I don't understand.
In Visfox I create a VCX for controls (e.g. textbox, label, combobox etc ) and inherit from the windows controls. Customisation of these controls is visual so click on the properties and change the font size etc. In Winforms there doesn't seem to be any visual element to this I have to write all the code for it.
Am I missing something?
Cheers Graham
It's been many years since I used WinForms but if I remember visual inheritance and WinForms designer support in Visual Studio don't work the same as you would be used to from VFP or VB6. Basically you have to programmatically add designer support, or as you say programmatically update any control properties you want to change.
WPF and its successors are much better in this regard.
You could create a project where you subclassed any form widget in your way.
Then in every new solution, you include that project and use those classes at the top instead of: using System.Windows.Forms.Form
you would use : using MyUberCoolSystem.Windows.Forms.Form
Just like you had to do in VFP as I remember.
I would never do that again, personally. If I need to override something I'd do it in just this application, and not everything I did. Extending the functionality of classes is easy as needed. In all of my data objects, I override the ToString() to output a serialized json string of the data.
On Wed, Aug 18, 2021 at 7:04 AM Alan Bourke alanpbourke@fastmail.fm wrote:
It's been many years since I used WinForms but if I remember visual inheritance and WinForms designer support in Visual Studio don't work the same as you would be used to from VFP or VB6. Basically you have to programmatically add designer support, or as you say programmatically update any control properties you want to change.
WPF and its successors are much better in this regard.
[excessive quoting removed by server]
Hiya That's the problem.
I can't figure out how to create a subclassed version of a textbox for instance in the first place.
If I want to set every textbox in the system to 10pt I don't want to edit every control on every form to change the font size. I would just want to change it in the textbox base and compile.
The only way I can find in the help docs is to create a new usercontrol and put the textbox inside a usercontrol. Every form then has the new usercontrol and not a direct textbox. This seems like a right pitb
What am I missing?
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Stephen Russell Sent: 18 August 2021 17:12 To: ProFox Email List Subject: Re: [NF] Winforms
You could create a project where you subclassed any form widget in your way.
Then in every new solution, you include that project and use those classes at the top instead of: using System.Windows.Forms.Form
you would use : using MyUberCoolSystem.Windows.Forms.Form
Just like you had to do in VFP as I remember.
I would never do that again, personally. If I need to override something I'd do it in just this application, and not everything I did. Extending the functionality of classes is easy as needed. In all of my data objects, I override the ToString() to output a serialized json string of the data.
On Wed, Aug 18, 2021 at 7:04 AM Alan Bourke alanpbourke@fastmail.fm wrote:
It's been many years since I used WinForms but if I remember visual inheritance and WinForms designer support in Visual Studio don't work the same as you would be used to from VFP or VB6. Basically you have to programmatically add designer support, or as you say programmatically update any control properties you want to change.
WPF and its successors are much better in this regard.
[excessive quoting removed by server]
On Wed, 18 Aug 2021, at 5:34 PM, Graham Brown wrote:
What am I missing?
You're not missing anything. Visual inheritance in the Windows Forms designer does not work like VFP, Delphi or whatever. It didn't in 2002, and on inspection still doesn't now.
This is how you do it with a UserControl.
https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/creating-a...
Here’s a YouTube video I made about WinForms UserControl and how it does not work like our beloved FoxPro does.
Matt Slay
On Aug 20, 2021, at 6:01 AM, Alan Bourke alanpbourke@fastmail.fm wrote:
On Wed, 18 Aug 2021, at 5:34 PM, Graham Brown wrote:
What am I missing?
You're not missing anything. Visual inheritance in the Windows Forms designer does not work like VFP, Delphi or whatever. It didn't in 2002, and on inspection still doesn't now.
This is how you do it with a UserControl.
https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/creating-a...
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
Graham
I'd definitely consider Windows Presentation Foundation over Winforms if this inheritance thing is a problem for you, because WPF *does* support that sort of visual inheritance, and i will set you up for WinUI going forward.
I'd definitely consider Windows Presentation Foundation over Winforms if this inheritance thing is a problem for you, because WPF *does* support that sort of visual inheritance, and i will set you up for WinUI going forward.
Coincidentally, there is also a session about using WPF in Visual FoxPro at Virtual FoxFest that covers some of the fundamentals of WPF and how it's different from VFP and HTML.
https://virtualfoxfest.com/Sessions.aspx#WPF_Modern_UIs_in_VFP_Applications https://virtualfoxfest.com/Sessions.aspx#WPF_Modern_UIs_in_VFP_Applications
Hi all
Thanks for all your replies. Don't understand why Microsoft haven't sorted visual inheritance properly. WPF (sigh) another technology to study.
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Alan Bourke Sent: 20 August 2021 14:54 To: profoxtech@leafe.com Subject: Re: [NF] Winforms
Graham
I'd definitely consider Windows Presentation Foundation over Winforms if this inheritance thing is a problem for you, because WPF *does* support that sort of visual inheritance, and i will set you up for WinUI going forward.
Thanks for all your replies. Don't understand why Microsoft haven't sorted visual inheritance properly.
You're assuming that they view it as a problem. If they did they'd have fixed it in the .NET Core version of WinForms.
On Fri, Aug 20, 2021 at 8:44 AM Matt Slay mattslay@jordanmachine.com wrote:
Here’s a YouTube video I made about WinForms UserControl and how it does not work like our beloved FoxPro does.
That's a great demo, Matt!
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
Wow...I see you created that in 2019. I can't believe what I saw...I'd have expected it to work much better than that. VFP has been off-support officially for 4+ years by that time yet the "old girl" still looks better for designers given this obvious shortfall.
On 8/20/2021 8:44 AM, Matt Slay wrote:
Here’s a YouTube video I made about WinForms UserControl and how it does not work like our beloved FoxPro does.
Matt Slay
On Aug 20, 2021, at 6:01 AM, Alan Bourke alanpbourke@fastmail.fm wrote:
On Wed, 18 Aug 2021, at 5:34 PM, Graham Brown wrote:
What am I missing?
You're not missing anything. Visual inheritance in the Windows Forms designer does not work like VFP, Delphi or whatever. It didn't in 2002, and on inspection still doesn't now.
This is how you do it with a UserControl.
https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/creating-a...
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
That is a shortfall, but WPF does a lot of things that we would LOVE to have in VFP (e.g. CSS llke Styles, much better responsiveness than our anchors, etc.)
Eric
On Fri, Aug 20, 2021 at 12:26 PM MB Software Solutions, LLC < mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:
Wow...I see you created that in 2019. I can't believe what I saw...I'd have expected it to work much better than that. VFP has been off-support officially for 4+ years by that time yet the "old girl" still looks better for designers given this obvious shortfall.
On 8/20/2021 8:44 AM, Matt Slay wrote:
Here’s a YouTube video I made about WinForms UserControl and how it does
not work like our beloved FoxPro does.
Matt Slay
On Aug 20, 2021, at 6:01 AM, Alan Bourke alanpbourke@fastmail.fm
wrote:
On Wed, 18 Aug 2021, at 5:34 PM, Graham Brown wrote:
What am I missing?
You're not missing anything. Visual inheritance in the Windows Forms
designer does not work like VFP, Delphi or whatever. It didn't in 2002, and on inspection still doesn't now.
This is how you do it with a UserControl.
https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/creating-a...
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
That text goes into the details of how I said to do it. Thus I agree that it can be done and re-used.
Now the Q I have is WHY? If you have branded UI button styles? What else are you extracting to re-use with your enhancements on time and again? Create the control library project
Define a custom control and its custom designer in C#/VB
Get your using using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System.Drawing.Design; using System.Windows.Forms; using System.Windows.Forms.Design;
Start coding off of it inherriting from a class public class MarqueeControlRootDesigner : DocumentDesigner
Due to all of this work I wouldn't do every control out there myself.
You can do the same thing in the Web space as windows forms so tOmato tomAto.
20 years ago the idea of subclassing every little thing was novel. Today I just don't have the time to do that because it isn't worth it.
Another good idea is buying all of that dond for you via the various tool companies that support .NET. This is outdated https://visualstudiomagazine.com/articles/2015/09/01/9-top-net-ui-component-... but most of those companies are still doing what they do so well.
On Fri, Aug 20, 2021 at 6:01 AM Alan Bourke alanpbourke@fastmail.fm wrote:
On Wed, 18 Aug 2021, at 5:34 PM, Graham Brown wrote:
What am I missing?
You're not missing anything. Visual inheritance in the Windows Forms designer does not work like VFP, Delphi or whatever. It didn't in 2002, and on inspection still doesn't now.
This is how you do it with a UserControl.
https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/creating-a...
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
Hi Alan
"Programmatically add designer support"?
Hmm how does that work, do you know of any resources to read up on?
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Alan Bourke Sent: 18 August 2021 13:04 To: profox@leafe.com; profoxtech@leafe.com Subject: Re: [NF] Winforms
It's been many years since I used WinForms but if I remember visual inheritance and WinForms designer support in Visual Studio don't work the same as you would be used to from VFP or VB6. Basically you have to programmatically add designer support, or as you say programmatically update any control properties you want to change.
WPF and its successors are much better in this regard.
[excessive quoting removed by server]