Hey there, so i have small problem, my application has mainForm and settingsForm, so is there only possible way to get settingsForm to be started only on first time user starts application so he can configure correct configs and then after it any other starting of application user gets mainForm started?? Is it possible? How if it is?
You can create a boolean settings variable with a name like FirstTime and set it to True. When your app starts, check the value of FirstTime. If it is true then hide the main form and display the settings form. Then set FirstTime to false and save it. If you give it User scope then the settings form will be displayed the first time for each user.
Sure thing. See attached vb 2010 project. Note, the Hide and Show are optional. It depends on whether or not you want the main form to be visible. I included a Reset button so you could reset the flag back to True otherwise you'd only be able to test it once.
I need since i made some textboxes to load files and when user click button on form 1 it should open those files so if i change twice files i will need to close app and start it again right? anyway My.Settings.FirstTime = False on close button fixed problem :)
I installed visual Studio 2012 (hate the look and feel of the "flat" interface) and loaded up your project. The reason it isn't working is because you didn't add the suggested code. If you want to display Settings on first run then you have to add code in the Form_Load event handler. Have another look at the sample project I posted earlier.
This is so very simple. On your Main form on it Form_Load try this.
Dim firsttime As String = "done"
' Check from file if the file exist or not, if the file
' Exist that means the program is not running the first time
My.computer.FileSystem.WriteAllText("C:\firsttime.txt", firsttime, True)
'Call the form2 as Setting form
Creating a file when a flag will do is not the way to go, especially a file in the location (root of C) that you are suggesting. The location is unrelated to the application and the filename gives no indication of what the file is for. All in all a very bad idea.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...