VB.Net Dynamic Controls

Sharky Forums


Results 1 to 5 of 5

Thread: VB.Net Dynamic Controls

  1. #1
    Goldfish
    Join Date
    Jun 2001
    Location
    Savannah GA, USA
    Posts
    86

    VB.Net Dynamic Controls

    Ok, my code is being weird and i don't why... (no scoffing for me using VB i chose this language for this project because of the ease to connect to a MS Access DB)

    I've got a Dynamic control,
    Code:
    Dim eventlabels As Label()
    Code:
    eventlabels = New Label(currentevents.Length - 1) {} 'define array size
    For x As Integer = 0 To eventlabels.Length - 2
        eventlabels(x) = New Label
        Select Case currentevents(x).getEventDate
             Case datearray(0)
                   gpbSun.Controls.Add(eventlabels(x))   'adding labels to
             Case datearray(1)                                  'correct groupbox
                   gpbMon.Controls.Add(eventlabels(x))
             Case datearray(2)
                   gpbTues.Controls.Add(eventlabels(x))
             Case datearray(3)
                   gpbWed.Controls.Add(eventlabels(x))
             Case datearray(4)
                   gpbThur.Controls.Add(eventlabels(x))
             Case datearray(5)
                   gpbFri.Controls.Add(eventlabels(x))
             Case datearray(6)
                   gpbSat.Controls.Add(eventlabels(x))
        End Select
        With eventlabels(x)                            'setting properities of labels
              .Size = New System.Drawing.Size(12, 12)
              .Text = currentevents(x).getEvent
              .Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
              .AutoSize = True
              .Hide()
              .Enabled = True
              .Visible = True
              .Location = New System.Drawing.Point(10, 15000)
              .Show()
        End With
        AddHandler eventlabels(x).Click, AddressOf EventLabelHandler
    Next
    now for whatever reason the .font isn't changing when the form displays... i pulled that line straight out of the default define (created by the compiler.. ok well IDE) for another label i have on the form... anyone have a clue as to why this wouldn't change the font property... In addition the .location doesn't change no matter what i set the new draw point to.

    help is much appreciated
    ACK I think i blew it up...

  2. #2
    NullPointerException rock's Avatar
    Join Date
    Sep 2000
    Location
    York, PA
    Posts
    6,203
    Maybe you may need a call to Refresh() to update the form after tweaking the properties?

    Open Source is free like a puppy is free.

    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.

    Understanding Evolution

  3. #3
    Ultra Great White Shark!! richardginn's Avatar
    Join Date
    Feb 2001
    Posts
    16,118
    How many times in the program are you changing the font???

    You might be changing it one too many times.
    www.myeducational plan.com-come see my plan to fix the USA educational system. I hope this is sig legal. Major Site Design Update on July 18, 2006. On June 18, 2009 passed the 10,000 post mark. December 24, 2009: Major Theme change and more....

  4. #4
    Goldfish
    Join Date
    Jun 2001
    Location
    Savannah GA, USA
    Posts
    86
    tried the redrawing/refreshing the form, no changes... only time i'm changing the font is when i create the labels..... the dynamic controls in VB.NET are a little touchy... funny i started a new project and tried the same code it works just fine... maybe there is something up with the IDE... thanks for the suggestions.
    ACK I think i blew it up...

  5. #5
    Ultra Great White Shark!! richardginn's Avatar
    Join Date
    Feb 2001
    Posts
    16,118
    Quote Originally Posted by JGC84
    tried the redrawing/refreshing the form, no changes... only time i'm changing the font is when i create the labels..... the dynamic controls in VB.NET are a little touchy... funny i started a new project and tried the same code it works just fine... maybe there is something up with the IDE... thanks for the suggestions.
    That could happen.
    www.myeducational plan.com-come see my plan to fix the USA educational system. I hope this is sig legal. Major Site Design Update on July 18, 2006. On June 18, 2009 passed the 10,000 post mark. December 24, 2009: Major Theme change and more....

Posting Permissions

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