Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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.

Posted
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???

  • *Experts*
Posted

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

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...