|
-
Jun 29th, 2005, 10:16 PM
#1
Thread Starter
Member
label problem......
HI...
the codes below is working fine...if i dun put this line (Label4.Visible = False) of code..but, if i place it in the codes as it is below then i have error
((((An unhandled exception of type 'System.NullReferenceException' occurred in OpenNETCFApplication4.exe)))
i want the label4 to be invisible......
this codes is only part of the program....
why is it so....???
can someone tell me y...thanxs in advance....
Code:
Public Function createLabels(ByVal slot() As String, ByVal booktime() As String)
groupbox2 = New OpenNETCF.Windows.Forms.GroupBox
Com = New System.Windows.Forms.ComboBox
Dim Label4 As New Label
Dim x As Integer = 15
Dim y As Integer = 30
Dim a As Integer = 85
Dim b As Integer = 30
Dim i As Integer
Dim counters As Integer
For counters = 0 To slot.Length - 1 Step 1
Dim newLinkLabel(counters) As OpenNETCF.Windows.Forms.LinkLabel
Dim newLabel(counters) As Windows.Forms.Label
newLinkLabel(counters) = New OpenNETCF.Windows.Forms.LinkLabel
newLabel(counters) = New Windows.Forms.Label
With newLabel(counters)
.Location = New Point(x, y)
.Visible = True
.Text = slot(counters)
.ForeColor = System.Drawing.Color.White
End With
Com.Items.Add(newLabel(counters).Text)
y = y + 17
b = b + 17
Next counters
Com.Location = New Point(112, 152)
Label4.Visible = True
Label4.Location = New Point(16, 152)
Label4.Text = "Select Slot:"
Label4.ForeColor = System.Drawing.Color.White
Controls.Add(Label4)
Controls.Add(Com)
End Function
Private Sub Com_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Com.SelectedIndexChanged
If Com.SelectedIndex = Nothing Then
MsgBox("Please select time")
Else
ComboBox1.Visible = False
ComboBox2.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Com.Visible = False
DateTimePicker1.Visible = False
groupbox2.Visible = True
groupbox2 = New OpenNETCF.Windows.Forms.GroupBox
groupbox2.Location = New Point(15, 40)
groupbox2.Size = New Size(208, 180)
groupbox2.Text = "Confirm Booking"
groupbox2.BackColor = System.Drawing.Color.Purple
groupbox2.ForeColor = System.Drawing.Color.White
Me.Controls.Add(groupbox2)
ptextbox = New System.Windows.Forms.TextBox
ptextbox.Location = New Point(16, 24)
ptextbox.Size = New Size(176, 112)
groupbox2.Controls.Add(ptextbox)
pbutton = New System.Windows.Forms.Button
pbutton.Location = New Point(16, 136)
pbutton.Size = New Size(176, 32)
pbutton.Text = "Submit Booking"
AddHandler pbutton.Click, AddressOf pbutton_click
groupbox2.Controls.Add(pbutton)
MenuItem2.Enabled = True
PictureBox2.Visible = True
End If
End Sub
-
Jun 29th, 2005, 10:21 PM
#2
Re: label problem......
Isn't Label4 out of scope in that example? It seems to be declared in the function createLabels.
Bill
-
Jun 30th, 2005, 12:28 AM
#3
Re: label problem......
Yes, declare Label4 in your class' scope, so that all methods can access it.
-
Jun 30th, 2005, 12:53 AM
#4
Thread Starter
Member
Re: label problem......
yap..thanxs....solved the problem.....
-
Jun 30th, 2005, 01:59 AM
#5
Re: label problem......
Add [Resolved] to the thread title.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|