![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Enable User to Re-Order Programmatically Created Buttons on Form? All, I am using the following code (started from a sample from this group, I think) to programmatically create a series of buttons in a vertical strip on a form on Form Open. The buttons are named and ordered according to values in the data set. They are created in the order of the value of their "TimerPos", field in the data set. I am interested in enabling the user to re-order the buttons in the strip, and am looking for ideas on the smoothest way to do this. Are there methods I can use that would support doing this via drag and drop? Do I need to come up with some other method? If so, which of these are alternatives? (In order of preference.) Is there a smoother method I am not thinking of? 1. Enable the user to right-click on the button and type in the desired "Move To" location of the button, then have the code write the new location to the DB, increment the location of any button below that +1, and refresh the form. 2. Enable the user to right-click on the button and select "Move Up" or "Move Down" from a sub-menu, writing the new location to the DB, incrementing any location after that +1 for each click of "Move Up" (and vice-versa) and have the button move up. 3. Set up a form showing button names and positions, and have the user type in a number next to a button to reflect the desired position, then increment the buttons and refresh the form after. I can add whatever values I want to the DB, if that helps. There is nothing else on the form other than these buttons. Thanks, Patrick Code:: Me.QRY_ButtonsTableAdapter.Fill(Me.SRTimerDataSet.QRY_Buttons) Dim Row As Integer = 0 Dim ButLbls = SRTimerDataSet.Tables ("QRY_Buttons").AsEnumerable () Dim sortedButLbls = From tp In ButLbls _ Select tp _ Order By tp("TimerPos") For Each tp In sortedButLbls Row = Row + 1 'Increment up. Dim NewButton As New MyButton() ' Sets a new button NewButton.Width = 123 ' Sets the width. NewButton.Height = 42 ' Sets the height. NewButton.Top = 1 + (42 * Row - 1) ' Positions the top of the button. Me.Controls.Add(NewButton) 'Adds the new button to the form. NewButton.Name = (tp!TimerPos) NewButton.Text = (tp!butLabel) AddHandler NewButton.Click, AddressOf ButtonResponder oTimeSliceCollection.Add(NewButton, tp ("TimerPos").ToString) Next |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Enable remote WMI programmatically? | VB Script | |||
| RE: Enable remote WMI programmatically? | PowerShell | |||
| Enable remote WMI programmatically? | PowerShell | |||
| Form created on BackGroundThread | .NET General | |||
| Temporary user profile created when user logs into domain | Vista networking & sharing | |||