Closed paul1956 closed 1 year ago
@paul1956 I am sorry unfortunately I don't know anything about VB :( I don't even understand what you are asking 🤷♂️
When you create a chart legend, title, etc are private I need them declared with wider scope.
When you create a chart legend, title, etc are private I need them declared with wider scope.
Unfortunately it didn't get clearer 🙄
This is the Control and for Chart you can set Modifiers. I don't see how to do that with the items in Chart like ChartArea, Legend, Series, Titles There are no Design Properties.
Name for example is in "Data" section not Design Properties.
I think I understand what you mean. You are talking about chart elements that are locals in InitializeComponent
?
They are locals - not private, so you can't to do anything here. I agree with you that this approach is not always convenient. But it was designed that way, and it was done for a reason. These are the internal elements of the chart and control monitors their life cycle. If you want to use them outside somehow, you'll have to get them from the chart one way or another. And if you are going to store them in global variables (class members), then you need to remember two things:
Yes, you now understand, if you look at TabPages which is similar the IDE allows you to declare them with other visibility below is Friend. If there are no events raised I agree it is not a good idea to expose.
Me.Users = New System.Windows.Forms.TabPage()
Friend WithEvents Users As TabPage
I am guessing this is only really important if the Object raises events.
@paul1956
TabPage
is not a good example here, because TabPage
is a Control
itself. DataGridView
with DataGridViewColumn
is more suitable, but DataGridViewColumn
is component too (derived from IComponent
)...
GenerateMember
and Modifiers
are not real properties. They are automatically added by designer in design time only, when you inherit your class from IComponent
Interface.
And TabControl
and DataGridView
was designed with that TabPage
and DataGridViewColumn
are components in mind.
But Chart
control was designed with opposite approach.
I did a quick test to demonstrate the problems.
The main problem is after we generate member, we will be able to select it and edit properties directly - ignoring all Chart collection editors logic. For example, we will loose all elements dependences by names - editing controls directly can lead to unpredictable errors :(
Other problems (I think they solvable): Name property conflict and GenerateMember
must be false
by default.
P.s. While playing with this I found bug in WinForms designer.
As long as the thing does not raise events, the way you are doing it is fine. I just need to access it by name and VB has an easy way to do that similar to C# using. It's where there are events that VB is different then C# and Visual Studio automatically can create the strongly typed handlers.
I don't understand why Name is under Misc when for other controls it is under Design except for that since the only thing that raises event as far as I can tell is Chart there is no real issue and this can be closed.
I don't understand why Name is under Misc when for other controls it is under Design
If you look at the screenshot above, then it is present both there and there. And I think it's due to that name of the varibale is differ from name property:
except for that since the only thing that raises event as far as I can tell is Chart there is no real issue and this can be closed.
Closing it then...
@kirsan31 In case you were wondering what I was up to. This is a medical app for people to monitor an insulin pump with analyze of its data on other tabs. Thanks for making it possible.
Glad to hear that someone needs it, especially for such a useful cause!
Right now, Legend, Title and other Chart Items in Designer are Local in designer.vb but for my application I want them Friend With Events is there a way to fix this without editing Designer.vb?
The resource designer has an option to control visibility in designer need something like that for custom controls. or just this one.