From: Patrick A on
All,

I've searched and read and tried for 3 hours, but I'm still stuck.

I have a form (frmMain) with a series of buttons I am creating in
code.

The labels, colors, etc. for each button are read from a DB via the
code below.

I have another form (frmSetupButtons) that the user can use to change
the labels, colors, etc.

Once the user changes a label, color, etc. and closes the Setup Button
form, how do I get the labels, etc. on the buttons to update?

(If I close the app and open it again, it updates...but I can't figure
out how to force the update in code.)

Any suggestions for the proper combination of refreshing the Data Set
and then the form?

Thanks,

Patrick


Here is the code I use to create the buttons.

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

oTimeSliceCollection = New Collection
Me.QRY_ButtonsTableAdapter.ClearBeforeFill = True
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 'Iterate through the
collection.
Row = Row + 1 'Increment up.
Dim NewButton As New MyButton() ' Sets a new button
Me.Controls.Add(NewButton) 'Adds the new button to the
form.
NewButton.butID = tp!TimerID.ToString 'Pull the TimerID
from DS and use it.
NewButton.Name = (tp!TimerPos) 'Pull the TimerPos from
DS and use it as a tag.
NewButton.Text = (tp!butLabel) 'Pull the butLabel from DS
and use it as text.
NewButton.butLabel = tp!butLabel.ToString '
NewButton.butDesc = tp!butDesc.ToString 'Read the Work
Description from the DB.
NewButton.butDispCM = tp!DispCM.ToString 'Read the Cli/Mat
from the DB.
NewButton.butTask = tp!Task.ToString 'Read the Task Code
from the DB.
NewButton.butAct = tp!Activity.ToString 'Read the Activity
Code from the DB.
NewButton.butLoc = tp!Location.ToString 'Read the work
location from the DB.
NewButton.ContextMenuStrip = cmTimeButs
NewButton.BackColor = Color.FromName(tp!butColor) 'Read
the color of the button from the DB.
oTimeSliceCollection.Add(NewButton, tp
("TimerPos").ToString)
Next