-
May 22nd, 2012, 04:58 AM
#1
Create Button In VB.NET Programmatically And Save It as Permanence
Hi, All Experts ... Argent, Please HELP ...
How to create a Button in Runtime and save it as Permanence. I Means to create Button or any control using coding but need it to save for next time using without using database to keep. Eg: Create a button during runtime, and the control will save permanencely for next use.
-
May 22nd, 2012, 06:15 AM
#2
Re: Create Button In VB.NET Programmatically And Save It as Permanence
Not sure what you mean? A dynamic button is a dynamic button. Whether you save the settings for this button in an INI file, or even the registry, it will still have to be created dynamically from there.
-
May 22nd, 2012, 11:57 AM
#3
Re: Create Button In VB.NET Programmatically And Save It as Permanence
Is this what you're looking for?
Code:
Public Class Form1
Private myButton As Button
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
myButton = New Button
myButton.Size = New System.Drawing.Size(80, 24)
myButton.Location = New System.Drawing.Point(40, 40)
myButton.Text = "myButton"
Controls.Add(myButton)
AddHandler myButton.Click, AddressOf myButtonClick
Catch ex As Exception
End Try
End Sub
Private Sub myButtonClick()
Try
MessageBox.Show("OK")
Catch ex As Exception
End Try
End Sub
End Class
Curt
-
May 22nd, 2012, 08:45 PM
#4
Re: Create Button In VB.NET Programmatically And Save It as Permanence
Originally Posted by HanneSThEGreaT
Not sure what you mean? A dynamic button is a dynamic button. Whether you save the settings for this button in an INI file, or even the registry, it will still have to be created dynamically from there.
Thanks, For Reply. YES, Currently I Save the setting in Local MS SQL Database, but every time in load slowly because too many setting inside, so what i want to find is the way to faster it ... Is that is i save those setting in .INI file will load faster ? Thanks.
-
May 22nd, 2012, 09:03 PM
#5
Re: Create Button In VB.NET Programmatically And Save It as Permanence
Well there would be less overhead reading from an INI file than an SQL Server database. So yes. However, that may not even be the source of your performance problems. Maybe there is something else causing it. Can't really be sure since we don't have the code you're using.
Try the INI file route and see if that improves it.
-
May 22nd, 2012, 09:15 PM
#6
Re: Create Button In VB.NET Programmatically And Save It as Permanence
Oh, Thanks, I Will Try it using .INI file, and Another Question, how to make a dynamic created Button can be moveable follow the mouse drag position ? thanks.
-
May 22nd, 2012, 09:16 PM
#7
Re: Create Button In VB.NET Programmatically And Save It as Permanence
By the way, how to write/read/create using .INI file ... Sry, I very fresh in VB.NET ... Thanks in advanced .
-
May 22nd, 2012, 09:56 PM
#8
Re: Create Button In VB.NET Programmatically And Save It as Permanence
Hi, Have anyone expert can tell me how to make faster Loading Control (Many Control) Like Button Dynamiclly Create at Runtime. The Loading for my from is slow and high latency until can see it load one-by-one. Becasue the Button Setting like position is all keep in Local Database. Thanks.
-
May 23rd, 2012, 01:05 AM
#9
Re: Create Button In VB.NET Programmatically And Save It as Permanence
Originally Posted by CKS2009
Oh, Thanks, I Will Try it using .INI file, and Another Question, how to make a dynamic created Button can be moveable follow the mouse drag position ? thanks.
As Curt_c mentioned in his code, use AddHandler. Here is a link explaining how it works :
http://msdn.microsoft.com/en-us/libr...=vs.71%29.aspx
Courtesy of Google.
Originally Posted by CKS2009
By the way, how to write/read/create using .INI file ... Sry, I very fresh in VB.NET ... Thanks in advanced .
Have a look here :
http://www.eggheadcafe.com/community...-ini-file.aspx
Also via Google.
Originally Posted by CKS2009
Hi, Have anyone expert can tell me how to make faster Loading Control (Many Control) Like Button Dynamiclly Create at Runtime. The Loading for my from is slow and high latency until can see it load one-by-one. Becasue the Button Setting like position is all keep in Local Database. Thanks.
That is what we are trying to do. But I think you show really show us some of your code; there might be something else causing all the problems.
-
May 23rd, 2012, 03:09 AM
#10
Re: Create Button In VB.NET Programmatically And Save It as Permanence
Originally Posted by HanneSThEGreaT
Thks, but can gif any sample code on it ... i still cant successful apply for my case ... Thanks
-
May 24th, 2012, 11:36 AM
#11
Re: Create Button In VB.NET Programmatically And Save It as Permanence
Hi,
How many buttons are you creating on your form? if there's any delay it's probably from reading the database and not form creating the controls
Why don't you just use 2 variables to locate your controls? Store those in a ini file.
Code:
Public Class Form1
Private myButtons(30) As Button
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer = 0
Dim xStep As Integer = 40
Dim yStep As Integer = 20
Try
For i = 0 To myButtons.Length - 1
myButtons(i) = New Button
myButtons(i).Size = New System.Drawing.Size(80, 24)
myButtons(i).Location = New System.Drawing.Point(xStep, yStep)
myButtons(i).Text = "Button " & i
'myButtons(i).Visible = False
Controls.Add(myButtons(i))
AddHandler myButtons(i).Click, AddressOf myButtonClick
yStep += 40
If i = 9 Or i = 19 Then
xStep = xStep + 100
yStep = 20
End If
Next i
'For i = 0 To myButtons.Length - 1
' myButtons(i).Visible = True
'Next i
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub myButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
MessageBox.Show(sender.ToString())
Catch ex As Exception
End Try
End Sub
End Class
Curt
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|