hiding some toolbar button

bshaen

Newcomer
Joined
Mar 10, 2005
Messages
19
i have build a toolbar with different button in usercontrol which will allow many forms to refer it,

user control toolbar include:
save, edit, delete, print, next, previous....

form1
save, next, previous

form2
print, save, delete

my problem is how to hide the toolbar button which i not declare.
 
Sounds like you might be trying to force a generalization. It doesn't really make sense to use the more general toolbar control you wrote for either form1 or form2. I mean, you could do it, but it looks like it would be a hack. You don't even use the edit button so why would you want it there? Unless this is a special toolbar, the standard .Net one is really easy to use. You could probably code it up in under 5 minutes with the drag and drop, assuming you have the images ready to roll.

Another option if you REALLY want to use your toolbar is to simply deactivate the buttons you don't need. They'll still be up there but they will be greyed out.
 
mskeel said:
Sounds like you might be trying to force a generalization. It doesn't really make sense to use the more general toolbar control you wrote for either form1 or form2. I mean, you could do it, but it looks like it would be a hack. You don't even use the edit button so why would you want it there? Unless this is a special toolbar, the standard .Net one is really easy to use. You could probably code it up in under 5 minutes with the drag and drop, assuming you have the images ready to roll.

Another option if you REALLY want to use your toolbar is to simply deactivate the buttons you don't need. They'll still be up there but they will be greyed out.

so based on ur opinion, what kind of method should i using?? and what ur mean of code it up in under 5 minutes with the drag and drop?? can u give me some examples to refer???
 
I would imagine that your have a public boolean properity for each toolbar button. Reference a sub routine that either shows or hides the buttons based on that boolean value.

in the class' declaration section add
Visual Basic:
Private _save as Boolean = False

then for the public properity use:
Visual Basic:
    Public Property Save() As Boolean
        Get
            Return _save
        End Get
        Set(ByVal Value As Boolean)
            _save = Value
            CheckButtonState()
        End Set
    End Property

then elsewhere in the class set the CheckButtonState sub
Visual Basic:
CheckButtonState()
if _save = True Then btnSave.Visible = True
if _save = False Then btnSave.Visible = False

'do the same for all the toolbar buttons
MyBase.Invalidate()
End Sub

I think that should work
 
bshaen said:
so based on ur opinion, what kind of method should i using?? and what ur mean of code it up in under 5 minutes with the drag and drop?? can u give me some examples to refer???

I am referring to use of the Visual Studio Designer... I still say, unless your toolbar is special in some way (adds value that cannot otherwise be used easily such as docking or something) it would be easier and much cleaner to simply write the toolbar section of code for this from scratch using the .Net toolbar control instead of reusing your toolbar which has hard coded button types and isn't meant for what are trying to use it for.

What DiverDan has recomended will definately work, but I think it is a hack to make something fit where it couldn't naturally be used.
 
Back
Top