Question Custom Button & Custom Tab on Property Grid

Scribbly

Member
Joined
Jul 16, 2007
Messages
9
Programming Experience
3-5
I had a custom button on a Property Grid (on a Win Form):

VB.NET:
        For Each oControl As Control In Me.propertygridProduct.Controls
            Dim oToolStrip As ToolStrip = TryCast(oControl, ToolStrip)
            If oToolStrip IsNot Nothing Then
                oToolStrip.Items.Add(btnSave)
                SaveButton = btnSave
                Exit For
            End If
        Next

then I decided to display some properties using a custom Property Tab
VB.NET:
<PropertyTabAttribute(GetType(versionsPropertyTab), PropertyTabScope.Component)> _
Public Class Product

When I set the SelectedObject to a Product the custom Property Tab overwrites or displaces the custom button.

How can I either protect the button or re-add it to the ToolStrip after the custom Property Tab has been added??

Thanks.
 
...this works... but?

OK, I've added a handler to the Toolstrip's LayoutCompleted event:
VB.NET:
AddHandler oToolStrip.LayoutCompleted, AddressOf ToolStripLayoutComplete

ToolStripLayoutComplete checks for the presence of the Save Button and adds it if it's not there.

Is there a better way to do this?
 
Back
Top