usercontrol question.

I have a usercontrol that i developed.

This control have 20 imagebox

how do I do to control which picture will be showed in which imagebox (from the form that have the control)


explaining better, what i need is this:

I need a "property" of the usercontrol that allow me to change the pictures in everyone of the 20 images that it contains...

Is it hard??? can anybody help plz???

Thank You
S-L-D-Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sgayatriCommented:
For this you should create a property of your usercontrol and write code to change the pictures in everyone of these 20 controls
Can you just post the code in your user control.....
0
mmusanteCommented:
I suggest using a couple of methods:

Public Sub setPicture(Pic As Object, Idx As Integer)
...
End Sub

Public Function getPicture(Idx As Integer) As Object
...
End Function
0
mmusanteCommented:
You can also put two properties in your usercontrol:

Private m_objPicture As StdPicture
Private m_lPicIndex As Long

...

Public Property Get Picture() As StdPicture
    Set Picture = m_objPicture
End Property

Public Property Set Picture(objPicture As StdPicture)
    Set m_objPicture = objPicture
End Property

Public Property Get PicIndex() As Long
    PicIndex = m_lPicIndex
End Property

Public Property Let PicIndex(ByVal lPicIndex As Long)
    m_lPicIndex = lPicIndex
End Property
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

mmusanteCommented:
When you read/write the picture property you can use the PicIndex property to choose the right ImageBox
0
S-L-D-Author Commented:
well... i forgot something... the pictures that i want to put in the 20 image box is in a imagelist on the main project

only a idea:
could i put the index and the picture in one function only, like this:

public function GetImage (index as integer,picture as (dunno)

end function

thank you very much
0
atheekurrahmanCommented:

hi,
  try this. its from one of my user controls. Mail me if u find any trouble


----------control prop var-------

Private m_SkinDown As Picture
 
--------------------------------



Public Property Get SkinDown() As Picture
    Set SkinDown = m_SkinDown
End Property



Public Property Set SkinDown(ByVal NewValue As Picture)
    Set m_SkinDown = NewValue
   
    //set the picture here
   
    PropertyChanged "SkinDown"
End Property




----------UserControl functions--------------------------

Private Sub UserControl_InitProperties()
    'Initialize Properties for User Control
       
    Set SkinDown = LoadPicture("")

    // also include other stuff
End Sub





Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    // other stuff

    Set SkinDown = PropBag.ReadProperty("SkinDown", Nothing)
End Sub





0
mmusanteCommented:
If you use a imagelist control you can pass it's name as a property and then use it to set the images

like this:

Option Explicit
Const m_def_ilName = ""
Dim m_ilName As String

Public Property Get ilName() As String
    ilName = m_ilName
End Property

Public Property Let ilName(ByVal New_ilName As String)
    m_ilName = New_ilName
    PropertyChanged "ilName"
    setImages
End Property

Private Sub UserControl_InitProperties()
    m_ilName = m_def_ilName
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

    m_ilName = PropBag.ReadProperty("ilName", m_def_ilName)
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)

    Call PropBag.WriteProperty("ilName", m_ilName, m_def_ilName)
End Sub

Private Sub setImages()

    Dim iList As ListImage
    Dim Ctl As Object
   
    If m_ilName <> "" Then
        For Each Ctl In ParentControls
            If Ctl.Name = m_ilName Then
                Set iList = Ctl
                Exit For
            End If
        Next
        If Not iList Is Nothing Then
            ' you can set your images here
        End If
    End If

End Sub
0
mmusanteCommented:
Sorry ...

Dim iList As ImageList
0
mmusanteCommented:
Here the full setImages sub ...

Private Sub setImages()

    Dim iList As ImageList
    Dim Ctl As Object
    Dim J As Integer
   
    If m_ilName <> "" Then
        For Each Ctl In ParentControls()
            If Ctl.Name = m_ilName Then
                Set iList = Ctl
                Exit For
            End If
        Next
        If Not iList Is Nothing Then
            For J = 0 To iList.ListImages.Count - 1
                If J <= imG.UBound - imG.LBound Then
                    Set imG(imG.LBound + J).Picture = iList.ListImages(J + 1).Picture
                Else
                    Exit For
                End If
            Next
        End If
    End If

End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.