CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: drawing

  1. #1
    Join Date
    Mar 2001
    Posts
    44

    drawing

    i created a form called formMain. inside this form i created a picture box.
    inside the picture box, i created a image box and set the index property of the image box to 0.
    my problem is that how can i draw 20 image boxes (row 5, col 4) in the picture box?


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: drawing


    Dim nRow as Integer, nCol as Integer
    Dim nIndex as Integer

    for nRow = 1 to 5
    for nCol = 1 to 4
    '\\ If no image box, load a new one
    If imgControl.count = nIndex then
    Load imgControl(nIndex)
    End If
    '\\ Move the control to the correct place
    imgControl(nIndex).Top = (nRow -1) * imgControl(0).Height
    imgControl(nIndex).Left = (nCol-1) * imgControl(0).Width
    '\\ Increment the control index
    nIndex = nIndex + 1
    next nCol
    next nRow





    This assumes that your image control is called imgControl

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Mar 2001
    Posts
    44

    Re: drawing

    your code draws only 1 imgbox.
    i typed ur code in Private Sub Form_Load()
    and i set the imgbox index property to 0.
    what went wrong?



  4. #4
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: drawing

    In order to see the control you need to set it's visible property to true thus:

    for nRow = 1 to 5
    for nCol = 1 to 4
    '\\ If no image box, load a new one
    If imgControl.Count = nIndex then
    Load imgControl(nIndex)
    End If
    '\\ Move the control to the correct place
    imgControl(nIndex).Top = (nRow - 1) * imgControl(0).Height
    imgControl(nIndex).Left = (nCol - 1) * imgControl(0).Width
    '\\ make the image control visible
    imgControl(nIndex).Visible = true
    '\\ Increment the control index
    nIndex = nIndex + 1
    next nCol
    next nRow




    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured