I am creating a SF User Control with a ThemedtoolStrip to be used with the enhanced functionality of the ListView (AddObject, DeleteObject and EditObject). After I finished the user control and dropped on a form, I can not select any buttons in the toolstrip to be assigned to the ListView, the only available object in this user control is the user control itself.
What am I missing here?
How to create a common ThemedToolStrip class to be used in several forms?
Hi Keith,
Thanks for the hint, I have tried setting the ThemedToolStrip and its buttons Modifiers to Protected Friend and all other options and still I am not able to access the ThemedToolStrip buttons to be assigned in the ListView properties.
Any other suggestions?
What you will need to do is expose the internal controls within the user control as properties. You may then have to programatically set the AddObject, EditObject, etc. via code then to the properties as the reflection type editor is not going to look at properties as well as controls on the form. You could get more complex and emit the properties dynamically, but this gets more complicated.
When you create a control, all internal controls are encapsulated to that control and the only way to access the internal controls is via code or by exposing them via another property, etc.
Then what would be the .NET way to minimize maintenance when using basically the same control in several forms?
All I want to do is have a single ToolStrip to handle some child BO functionality in several forms, I can get away with not creating the User Control and then just copy/paste the ThemeToolStrip all over, but there should be a better more efficient way to handle this. What approach should I take?
Agreed, this sound a bit more complicated even though I do understand the process to get it done.
Go at it from the other direction. Create a toolstrip, then subclass the ListView. On the ListView, create a property that is typed as the custom toolstrip that you created. When you drop the ListView on the form, you can then attach the Toolstrip to the ListView using that property. This is the same approach that we use on our RichTextToolstrip and our RTF control...it would probably give you some ideas.
Also, while we are on the subject, I did add another property to the ListView to let you decide whether the record will be marked as deleted or actually "smoked" from the database
Also thanks for the new delete flag property, that will save us from having to code around it and looks much more clean.