Exposing internal objects of a user control in the properties view of the designer? - vb.net

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

Related

How can I remove all properties of a user control?

I am working on a Visual Basic project and I had to create my own user control. I want to remove-hide ALL default properties of this user control but not by using this <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> way, one by one property. I need something more massive.
I'm afraid what you want to do isn't possible in VB, as it would require to add the attributes dynamically (on all properties) and in VB attributes are static and cannot be added or removed dynamically.
The only way to do what you want to do is to add the attributes one by one property.

Visual Basic 2010 - Referencing objects in different user controls

For an app that uses user controls instead of forms and the first user control has a listview, where the user clicks or selects "Create New" Or Delete, what is the best way to transfer the data selected in the listview to the detail screen (separate User Control) where the data can be edited?
Can I just reference the list view in the first UC in the Details UC? something like:
ucHeader.lvSetups.FocusedItem.SubItems.Count = 0
from the ucDetail user control?
Saying which way is the best would produce a heated discussion with every ones opinion. However, here are a few ways I would tackle this. While there are more options, these are what I would do:
You should expose any information you want to read from a user control in the form of a property, readonly if you must. Just an example because I don't know what your object types are:
Public ReadOnly Property SelectedItem as object
get
Return Listview1.SelectedValue
end get
End Property
You can also use events to tell the parent of your user control that a selection was made. You can pass whatever you want in this event, even the selected object. If you don't want to pass the selected object, grab it from the property you created (like #1) in the event handler.

Set tag of a ListBox item

Is it possible to set the Tag property of an individual item of the ListBox instead of only the whole control?
I tried
listbox.Items(i).Tag = "Test"
Unfortunately without any luck.
That's not how ListBox works. It doesn't have a dedicated item type like TreeView or ListView has, there is no ListBoxItem class. So there's no Tag property either.
ListBox is far more general, it accepts any object in its Items.Add() method. The rule is that whatever object you add needs to override the ToString() method. That's what ListBox uses to display the text for the item. Which then also removes the need for a Tag property. Just cast the object you get back from, say, listBox1.Items[listBox1.SelectedIndex] back to your class type.
Do consider ListView if that's hard to deal with, setting its View property to List gets you a list box too. With a Tag property for the ListViewItems you add.

Collection Type Property For User Control

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).

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.