|
-
Apr 29th, 2020, 08:11 AM
#1
Thread Starter
Member
Easy way to clear an array of images in design mode?
I'm working with a large array of Image objects, which I have loaded with actually images in design mode to make it simple to drag them around. Once I'm satisfied with their placement, I want to clean up and clear the images loaded in those controls. Obviously, I can clear them one at a time, but that's really time consuming. Is there a faster way that I'm not thinking of? I considered writing a program to modify the .frm file directly, but I figure that'd only end up messing up the .frx file.
-
Apr 29th, 2020, 09:19 AM
#2
Re: Easy way to clear an array of images in design mode?
Add an UserControl to the project.
Set the property EditAtDesignTime to True.
Set the property InvisibleAtRunTime to True.
Add a CommandButton to the UserControl.
Copy this code to the UserControl code module:
Code:
Private Sub Command1_Click()
Dim an As String
Dim ctl As Control
an = InputBox("Please enter image array control name")
If an <> "" Then
For Each ctl In Parent.Controls
If TypeName(ctl) = "Image" Then
If ctl.Name = an Then
Set ctl.Picture = Nothing
End If
End If
Next
End If
End Sub
Add an instance of the UserControl to the form.
Right click on the UserControl at design time, and select 'Edit'.
Click the CommandButton.
Enter the name of the Image control (for example 'Image1')
Click OK.
-
Apr 29th, 2020, 09:31 AM
#3
Thread Starter
Member
Re: Easy way to clear an array of images in design mode?
 Originally Posted by Eduardo-
Add an UserControl to the project.
Set the property EditAtDesignTime to True.
Set the property InvisibleAtRunTime to True.
Add a CommandButton to the UserControl.
Copy this code to the UserControl code module:
Code:
Private Sub Command1_Click()
Dim an As String
Dim ctl As Control
an = InputBox("Please enter image array control name")
If an <> "" Then
For Each ctl In Parent.Controls
If TypeName(ctl) = "Image" Then
If ctl.Name = an Then
Set ctl.Picture = Nothing
End If
End If
Next
End If
End Sub
Add an instance of the UserControl to the form.
Right click on the UserControl at design time, and select 'Edit'.
Click the CommandButton.
Enter the name of the Image control (for example 'Image1')
Click OK.
Thanks Eduardo. But I'm not familiar with the EditAtDesignTime or InvisibleAtRunTime properties. Are you referring to VB6?
-
Apr 29th, 2020, 09:44 AM
#4
Re: Easy way to clear an array of images in design mode?
-
Apr 29th, 2020, 09:49 AM
#5
Thread Starter
Member
Re: Easy way to clear an array of images in design mode?
 Originally Posted by Eduardo-
Yes.
Okay, so where can I find these properties. I created a command button but I've never heard of those properties. (Sorry, I'm a programming hobbyist so I only know half there is to know about VB6.) Can you at least point me in the right direction?
Okay, I figured out how to create the user control and then add an instance of it to my program. When I try to use it, however, it doesn't actually work.
Last edited by schnel; Apr 29th, 2020 at 10:10 AM.
-
Apr 29th, 2020, 10:14 AM
#6
Thread Starter
Member
Re: Easy way to clear an array of images in design mode?
Thanks a lot. I figured it all out. Now I have a lot to learn about User Controls.
-
Apr 29th, 2020, 10:42 AM
#7
Re: Easy way to clear an array of images in design mode?
You can check the description and usage of any property here (click the Properties link).
Tags for this Thread
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
|