I had a giant form with lots of controls "ImageList" located in its header and the corresponding controls "ImageCombo" in the detail of the form.
The "ImageList" and "ImageCombo" controls were initialized and are loaded in the "Form_Load" event.
The form is not linked, yet, with a database.
I changed the giant form to a smaller one with a "TabControl" with four pages.
I used the method of cut and copy controls.
The "ImageList" controls remain at the form header.
One of the controls "ImageCombo" is in the form header.
Now, when I run the form, all controls "ImageCombo" appear without images or text except that remains in the header.
I have tried to initialize and load the "ImageList" and "ImageCombos" within each page of the "TabControl", but when I switch the page and come back, all "ImageCombo" are empties.
I searched internet solutions and examples and I guess the error is in how to identify each control in the field of each page, but I failed in all my tests.
Breixo, It would be better if you showed some things you've already tried. Hard to know if how to help you. But I'll start with pointing you to this page. I think your problem is how to reference objects on a tab within a tab control. https://msdn.microsoft.com/en-us/lib...ffice.12).aspx
Thanks for your answer and your time. First of all, I am a beginner and I replace my shortcomings based on hours of searching for solutions on the internet and hours of trial and error and I just turn to this forum when I'm definitely stuck.
Indeed, I had already read the linked page, again and again, but I have it clear that I have not been able to understand the strange bond between "ImageList" and "ImageCombo" controls when placed on a "TabControl".
I include my little test program and a graphical view of what is happening to me.
OK, this thing is a mess. These are VB6 era controls. You probably should attempt to replace them with an alternative solution as soon as you can convince your customer/users of doing this a different way.
I'm not sure if the control is being destroyed or just the handle to it is being lost, but either way, when the tabControl shows a different tab, the properties for the ImageCombo are lost. So to fix this, the control needs to be re-initialized and the selected item needs to be reselected whenever a different tab is shown to the user.
First thing is to save off the Value of the ImageCombo so that it can be reset later. It looks like the .Tag property was being used before, so I reused it. VB6 loved the .Tag property.:
Expand|Select|Wrap|Line Numbers
Private Sub ImageCombo01_Exit(Cancel As Integer)
ImageCombo01.Tag = ImageCombo01.SelectedItem
End Sub
You might be able to save off the .Index, to speed things up, but I got this working and stopped there.
Next, tweak the initialize routine for the ImageCombo, so that it reselects the value:
Expand|Select|Wrap|Line Numbers
Public Function setImageCombo01Selection()
If ImageCombo01.Tag = Null Then
ImageCombo01.Tag = 1
ElseIf Len(ImageCombo01.Tag) > 0 Then
' Find the Previously Selected Item
For Each oItem In ImageCombo01.ComboItems
If oItem = ImageCombo01.Tag Then ImageCombo01.SelectedItem = oItem
Exit For
Next oItem
Else
' Select the default item.
Set ImageCombo01.SelectedItem = ImageCombo01.ComboItems(3)
End If
End Function
Lastly, reinitialize the ImageList and ImageCombo when the Tab is changed:
Expand|Select|Wrap|Line Numbers
Private Sub tabControl01_Change()
Select Case Me.tabControl01.Value
Case 0
Call Load_ImageList01
Call Load_ImageCombo01
Case 1
Call Load_ImageList02
Call Load_ImageCombo02
End Select
End Sub
This could be much prettier, but I'll leave that up to you.
Thanks, jforbes, but I've been testing and combinations throughout the weekend and I've just gotten me out errors such as "The key is not unique" and others.
I dare to abuse your time asking you to put me in my code should go where and how the routines that you have enclosed me.
Forgive my boldness but I have two weeks without knowing how to solve this problem.
Well, after "throwing in the towel" I've follow "testing" and I've gotten that ImageControls appear correctly when switching pages of the TabControl. To do this I've changed slightly your code:
First off all, I don't load the second ImageControl (in page02) until I commute the TabControl to the page02:
Expand|Select|Wrap|Line Numbers
Private Sub Form_Load()
Call load_ImageList00
Call Load_ImageList01
'Call Load_ImageList02
Call Load_ImageCombo00
Call Load_ImageCombo01
'Call Load_ImageCombo02
End Sub
Here are the variations of your code (This routine gave me many incomprehensible errors):
Expand|Select|Wrap|Line Numbers
Public Function Load_ImageCombo01()
With ImageCombo01.ComboItems
.Add Text:="Unknown", Image:=1
.Add Text:="Non Toxic", Image:=2
.Add Text:="Toxic", Image:=3
End With
If Len(ImageCombo01.Tag) > 0 Then
' Find the Previously Selected Item
For Each oItem In ImageCombo01.ComboItems
If oItem = ImageCombo01.Tag Then ImageCombo01.SelectedItem = oItem
Exit For
Next oItem
Debug.Print "NEW01="; ImageCombo01.SelectedItem
Else
' Select the default item.
Set ImageCombo01.SelectedItem = ImageCombo01.ComboItems(1)
Debug.Print "DEF01="; ImageCombo01.SelectedItem
End If
End Function
Finally, the code for the TabControl switch:
Expand|Select|Wrap|Line Numbers
Private Sub tabControl01_Change()
Select Case tabControl01.Value
Case 0
ImageList01.ListImages.Clear
Call Load_ImageList01
Call Load_ImageCombo01
Case 1
ImageList02.ListImages.Clear
Call Load_ImageList02
Call Load_ImageCombo02
End Select
End Sub
So far, everything seems fine. The ImageControls are loaded correctly and thus always remain when the TabControl is switched.
But, whenever you switch to the other page the ImageControls return to the "default".
I've tried both in the event of "Exit" and "Update" with the following code;
Hello,
I would like to change the Forecolor of a comboItem (of a ImageCombo),
but I can't make it.
I can't see any forecolor in the method or properties.
If I change the forecolor of the...
Is there a way for me to use an image file (JPG, GIF, BMP etc) on my tabs
instead of text? I see that if you go to the "Icon" property (of a tabPage)
then you can add a ICO file, but because an...
I have a problem that just cropped up with using an ImageList in my project
I am using VB .NET 200
Problem:
I have existing Form with 2 Image List controls. ImageList16 (for 16x16 Images) and...
hi there.
I am creating a tabcontrol where the drawing of the tabs is controlled by
me.
However, i cannot find a way to change the lenght of the tab.
For instance, "String" needs a smaller tab...
I currently have a tabcontrol with 5 tabs. instead of putting text in the
tabs i am using images. i created an image list and inserted the 5 images
and used them to display instead of text. ...
Hi,
I have a WinXPSP2, P4 3.2GHZ, 1GIG RAM on my dev machine using VS2005
VB.NET. I did the following procedure:
1. Added 82 icons (128x128 in size & 32bit Depth) in an imagelist
control
2....
Im trying to have some fun with the imagecombo control, but so far its alot more frustration then it is fun.
From what I have understood I can't tie the imagecombobox directly to a field in a...
Im using an imagecombo in my form, and I have its Text property set to "Please Select". The text property of the imagecombo is what is displayed when you have not yet made a selection, kinda like...
Hi to all,
I'm about to go crazy. Attached is a simple form with an ImageList control and an ImageCombo control.
The problem is that when I try to associate the ImageCombo with the ImageList, in...
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...