|
-
Oct 31st, 2001, 01:41 PM
#1
Thread Starter
Lively Member
copy control
I've got a control, named Winsock. I want to copy this control and rename it. is this possible? if yes, how?
VIP
-
Oct 31st, 2001, 01:44 PM
#2
PowerPoster
Edit Copy
Edit Paste
would do I should think...
-
Oct 31st, 2001, 01:45 PM
#3
-= B u g S l a y e r =-
u want to copy it using VB, use FileCopy ?
-
Oct 31st, 2001, 01:46 PM
#4
Thread Starter
Lively Member
something like that. I want to do this when the program is running. (when you click a button)
VIP
-
Oct 31st, 2001, 01:46 PM
#5
If you are doing the copy on the same form, it will ask if you want to create a control array. Say no, and the new control's name should default to WinSock1. It would be best to save the form first. That way you can always reload if something goes awhacky.
-
Oct 31st, 2001, 01:57 PM
#6
You must have posted at the same time I did. Anyway, I didn't realize you want to do this at runtime. Should be a problem though. First, in design mode, you will need to create a control array of your Winsock control. So, add a second control, give it the same name, and say "Yes" when asked if you want to create the array.
Now your control will be named something like Winsock(0).
The 0 represents the index of the array. Then, at runtime you can use Load to create a new control by saying
VB Code:
Private Sub cmbField_Click(Index As Integer)
If cmbField(0).Text = "** Find All Records **" And cmbOperator(0).Visible = True Then
Picture1.SetFocus
Exit Sub
ElseIf cmbField(0).Text = "** Find All Records **" Then
Exit Sub
End If
If cmbField(Index) > "" Then
'Load a new instance of the criteria and condition lists if needed...
On Error Resume Next
If Index >= 0 Then
Load txtCriteria(Index)
txtCriteria(Index).Top = txtCriteria(0).Top + (Index * 330)
txtCriteria(Index).Text = ""
Load cmbOperator(Index)
cmbOperator(Index).Top = cmbOperator(0).Top + (Index * 330)
cmbOperator(Index).Tag = ""
If Index < 4 Then
Load Condition(Index)
Condition(Index).Top = Condition(0).Top + (Index * 330)
If Condition(Index).ListCount = 0 Then
Condition(Index).AddItem "And"
Condition(Index).AddItem "Or"
End If
End If
End If
txtCriteria(Index).Visible = True
cmbOperator(Index).Visible = True
cmbOperator(Index).TabIndex = cmbField(Index).TabIndex + 1
txtCriteria(Index).TabIndex = cmbField(Index).TabIndex + 2
Condition(Index).TabIndex = cmbField(Index).TabIndex + 3
If Index < 4 Then
Condition(Index).Visible = True
End If
This is code that I use in one of my programs to programmatically create a series of combo boxes depending on what the users wishes (not show). You should be able to modify this to do the same with your Winsock control.
-
Oct 31st, 2001, 02:23 PM
#7
Thread Starter
Lively Member
thanks for your reply but the most inpotant thing of the hole action is the renaming. I want to rename the control after I copied it.
-
Oct 31st, 2001, 02:28 PM
#8
I don't believe you can programmatically rename a control at runtime. All you can do is Load a new instance of it.
-
Oct 31st, 2001, 02:30 PM
#9
Thread Starter
Lively Member
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
|