Collection Type Property For User Control - vb.net

Is it possible to create a user control with a list of custom class type property?
If it is, how can I?
The issue is that, in designer mode the property is not displayed in property window. I can add the list on markup but when i switch to the designer mode it gives an error which is 'The user control does not have a public property named BookList'.

I think that the problem that you have here is that your list property collection contains a custom class type.
You'll need to ensure that your custom collection class is declared public so that the designer can access it. You may need it to be declared within the same files as the custom control.
If the class contained within the collection is not easily displayed then you may also need to add a TypeConverter to the property and override GetStandardValuesSupported and GetStandardValues methods (maybe even GetStandardValuesExclusive too).

Related

Accessing to control inside of usercontrol

I am making an usercontrol with only one textbox so basically I expect that properties of textbox have to be applied to whole usercontrol.
That means (for example) that I would like from outside of usercontrol (in main program which contain those usercontrol) to get value of those (intern) textbox's selectionstart property.
But I can't find a way to do this except in creating a new public property of my UC.
I suppose that here should be some better way because textbox have many properties which may be needed to read (or maybe write) from main program and making another public property in UC for every internal property of textbox don't seems like "way to go" for me.
Any advice on how to get properties of internal control in UC from main program?
you may inherit your usercontrol from textbox control,liKe:
Class MyTextbox
inherits TextBox
End class
and then try to override, overload and access the events and properties you want.
you can check the following links,
1- For textbox inheritance example
2- Answered Question in Satckoverflow
Will not a regular FindControl check solve this?

Exposing internal objects of a user control in the properties view of the designer?

I've already had success exposing a collection of items in the vb.net designer using DesignerSerializationVisibility(Content). Now I have a new twist. The items in my collection for a certain custom control are immutable--i.e. items can neither be added nor removed. All I want is to expose the items of my collection in the properties panel of the designer so that a developer can tweak the individual properties of each item in the predefined collection of items.
When I tried DesignerSerializationVisibility(Content) it allows the developer to manage the items but rather than editing the existing items it attempts to re-add the items to the collection, which causes key collisions.
As a result I figured it might make sense to expose each item of the collection as its own property. I used DesignerSerializationVisiblity(Visible) and (Content) and both just display the type name in the properties window but the object it exposes is not visible in a way that it can have its properties manipulated.
Am I missing something or can this not be done? I read somewhere about using a TypeConverter. Is this right?
If I understand your Question correctly, you want to change a property to expandable property that has several sub-property.
If I understand properly, you must create a class that is derived from ExpandableObjectConverter. And use this class with TypeConverterAttribute for your property or that class that is related with your property.
For more information, please see my question that its link is offered in below:
Hide ellipsis (…) button of expandable property like “…” button of font property in the property grid

How can I add a property to System.Windows.Form.Control in VB.NET?

Is there a way to add a property to System.Windows.Form.Control base class without defining the new inherited class (in VB.NET) ?
I want to add a Tooltip property to all of System.Windows.Form.Control controls, which will be browsable in properties window of that control.
You want to write an extender provider.

ReadOnly Property ListView in ListViewItem - How is implemented?

Maybe someone know how ListView pointer is stored/removed at ReadOnly Property ListView in ListViewItem? How is it implemented? I know ListViewItems are stored in ListViewItemCollection which has constructor New(owner as ListView) but I dont know how pointer to ListView is add/remove in ReadOnly Property in ListViewItem...
A ListViewItem has a reference to its containing ListView in a member field. When you add a ListViewItem to a ListView, the ListView updates this member (this occurs within the private function ListView.InsertItems).
The read-only ListView property provides public, but read-only access to this internal member field. (The member field itself is not read-only.)
To learn more, download Reflector and use the Analyze command to track the various functions which can assign the internal listView field. Note that as the listView member is internal and the functions which modify it are private or internal, you should not rely on this implementation in your own code.

Can I change properties of inherited controls at design time?

I am using visual inheritance and was wondering if there is a way to change the properties of inherited controls at design time, preferably in the form designer. If not, then in the designer code.
I have my control declared as Public in the base class. I can access it in the child form code, but not in the form designer. Is this just not possible?
There are limitations placed within visual studio for visual inheritance. Unfortunately, derived forms\usercontrols cannot modify controls containing collections within the base, namely DataGridViewRows, ToolStrips, ListViewColumns, etc.
Microsoft Bug Report
There are ways around this in certain situations. Create a protected property in the base class that exposes the exact properties of the control you wish to modify (DataGridView.BackgroundColor, or ListView.Columns).
Your base form should be able access this property to change the components needed. I've done this for ListView.Columns, and DataGridView.rows successfully, however ToolStrip.Items would not work.
It seems to work only for certain controls, but not all and I can't understand why. On my base form I have a TabControl that within it is a ComboBox, a ToolStrip, and a DataGridView. All of them are set to Public, but I can only modify the properties of the ComboBox and not the other two controls.
I have no idea why this is.
You need to change your control visibility. Put the control property Modifiers on public and recompile the project and then you can change properties of the inherited control.