Click to See Complete Forum and Search --> : VB.Net Dynamic Controls


JGC84
10-30-2007, 10:07 AM
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,
Dim eventlabels As Label()

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 :confused:

rock
11-01-2007, 12:23 PM
Maybe you may need a call to Refresh() to update the form after tweaking the properties?

richardginn
11-05-2007, 06:20 PM
How many times in the program are you changing the font???

You might be changing it one too many times.

JGC84
11-07-2007, 07:03 AM
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.

richardginn
11-07-2007, 09:04 AM
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.