bshaen Posted March 22, 2005 Posted March 22, 2005 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. Quote
mskeel Posted March 22, 2005 Posted March 22, 2005 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. Quote
*Experts* DiverDan Posted March 22, 2005 *Experts* Posted March 22, 2005 You can also set the toolbar button's Visible properity to False when you're not using them. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
bshaen Posted March 23, 2005 Author Posted March 23, 2005 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??? Quote
*Experts* DiverDan Posted March 23, 2005 *Experts* Posted March 23, 2005 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 Private _save as Boolean = False then for the public properity use: 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 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 Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
mskeel Posted March 23, 2005 Posted March 23, 2005 so based on ur opinion' date=' 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???[/quote'] 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.