Hi me again I’ve come across another problem following my last 2 questions. Buttons to be renamed by the user and Input a button's text into a text box.
What happens is when label4 is admin when you click the button an input box appears asking for the button name and if label4 is anything else then it adds the text of the button to different boxes.
This all works fine the problem I’m having is when i close the program and then re open it all the buttons text has been removed.
So in short what im asking is how t\do I make it save to the button so that if I close the program and re open it the text stays on all the buttons.
The Code I have for the button is.
Dim Button As Button = DirectCast(sender, Button)
If Label4.Text = "Admin" Then
With DirectCast(sender, Button)
.Text = InputBox("Button Name", "Button Name", .Text)
End With
Else
Me.TransactionBindingSource.AddNew()
Product_NameTextBox.Text = Button.Text
Try
Me.ProductTableAdapter.FillByProductName(Me.Database1DataSet.Product, Product_NameTextBox.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
ProductTextBox.Text = Button.Text
GroupTextBox.Text = GroupTextBox1.Text
AmountTextBox.Text = AmountTextBox1.Text
PriceTextBox.Text = PriceTextBox1.Text
TimeTextBox.Text = TimeOfDay
DateTextBox.Text = DateString
Me.Validate()
Me.TransactionBindingSource.EndEdit()
Me.TransactionTableAdapter.Update(Me.Database1DataSet)
Timer2.Enabled = True
TransNameLB.Items.Add(Button.Text)
TransPriceLB.Items.Add(PriceTextBox.Text)
Dim sum As Double
For x As Integer = 0 To TransPriceLB.Items.Count - 1
sum += Val(TransPriceLB.Items.Item(x).ToString)
Next
TextBox1.Text = sum.ToString
QTYDrinksTB.Text = TransNameLB.Items.Count
End If
Thanking you in advance for any help provided
Craig
In addition to what Mark Hall said (excellent answer!), VB can do it all automagically for you. You have to set up a binding to the application setting.
is User
Now, the app will automatically remember the text you’ve set, and reload it on app startup