.Net Compact Framework LateBinding issue (Help Please)

T

TheGanjaMan

Hi,
I'm new to developing software for the Smartphone (in .net cf in general)
But I came across a problem that I really would appreciate some help
with.

I'm writing a small app. where a user enters some text in a textbox, and
after each entry a checkbox is formed on the form. (kind of like the
tasks in outlook) after the text entries are completed the user can
select any checkbox and mark them as complete. When a checkbox is marked
I want the text font to change (like strikethrough). But vs 2005 gives
me an error saying "late binding is not supported".

I'm writing code similar to the example below:
----------------------------------------------------------
Dim i As Integer = 0
Dim chkbox() As CheckBox

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
ReDim Preserve chkbox(i)
chkbox(i) = New CheckBox
chkbox(i).Text = TextBox1.Text
chkbox(i).Top = (i * chkbox(i).Height)
chkbox(i).Font = New Font("Arial", 12, FontStyle.Regular)
Controls.Add(chkbox(i))
AddHandler chkbox(i).CheckStateChanged, AddressOf
chkbox_StateChanged
i += 1
End Sub

Private Sub chkbox_StateChanged(ByVal sender As Object, ByVal e As
EventArgs)
If sender.checkstate = CheckState.Checked Then
sender.font = New Font("Arial", 12, FontStyle.Strikeout)
End If
If sender.checkstate = CheckState.Unchecked Then
sender.font = New Font("Arial", 12, FontStyle.Regular)
End If
End Sub
----------------------------------------------------------
the code above works if I don't use the checkbox as an array, but then
the sender.checkstate only works for the last added checkbox.
and if I use the code above the sender.font or sender.anything gives me
the late binding error...

any ideas people?
thanks in advance for any replies.
 
D

Daniel Moth

Not looking at all of your code but it is seems you need to cast (also make
sure you have Option Strict On in your project properties)...

The bit with
sender.XXX
should be
DirectCast(sender, CheckBox).XXX

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top