Click here to Skip to main content
15,898,987 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi am Developiong a Point of sale system, i want to load item category dynamically on a form as command buttons.the form will be divided into two sections. the category Section and the items Section. when i click the category command button. it will dynamically load the items under the select category as command buttons.

it is a touch screen point of sale. please assist.
Posted

1 solution

What is the problem? Where are you stuck?

Try something like:

For x As Integer = 0 to buttonCount - 1
   Dim newButton as Button

   newButton = New Button()
   With newButton
      .Name = "Category" & x.ToString & "Button"
      .Text = "Category " & x.ToString
      AddHandler newButton.Click, AddressOf myButtonClickEvent
      'You will need to position the buttons as well...
      Form1.Controls.Add(newButton)
   End With

Next x


And create the eventhandler to intercept your button click events:

Public Sub myButtonClickEvent(Byval Sender as Object, Byval e as System.EventArgs)
    MsgBox DirectCast(sender, Button).Name & " Clicked"
End Sub

All this written off the top of my head, so you will probably need to do a few adjustments...
 
Share this answer
 
v3
Comments
Dalek Dave 8-Oct-10 5:59am    
Couldn't have done it better myself!
Johnny J. 8-Oct-10 6:00am    
Thanks. But now you're modest - I'm sure Dalek powers could provide a 100% foolproof answer... ;-)
Simon_Whale 8-Oct-10 11:01am    
my vote of 5, as that answer works as I've used it before myself

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900