 |
|
| .NET DotNet Forum Index » General Discussion » Enable User... |
|
Page 1 of 1 |
|
| Author |
Message |
| Patrick A... |
Posted: Thu Nov 05, 2009 6:31 am |
|
|
|
Guest
|
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 |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Sun Nov 29, 2009 4:38 pm
|
|