I've got a control, named Winsock. I want to copy this control and rename it. is this possible? if yes, how?
VIP
Printable View
I've got a control, named Winsock. I want to copy this control and rename it. is this possible? if yes, how?
VIP
Edit Copy
Edit Paste
would do I should think...:confused:
u want to copy it using VB, use FileCopy ?
something like that. I want to do this when the program is running. (when you click a button)
VIP
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.
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 sayingThis 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.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
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.
I don't believe you can programmatically rename a control at runtime. All you can do is Load a new instance of it.
okey, thanks!
VIP