memory error using custom control property

T

Terry Brown

I have created a custom button for my app that repositions text for the
button by overriding the OnPaint method.

Everything works fine and I populate my form with custom controls, they
show up and work properly. I have 100 of these controls on one form.

I then modified my new button class to contain a property like this:

Public Property row() As Integer
Get
row = mrow
End Get
Set(ByVal Value As Integer)
row = Value
End Set
End Property

However, if I set this property when I create the control like this:

dim mybutton as new smallbutton
mybutton.row = 10

then when I deploy the application to the emulator, I get an out of memory
exception. If I remove the assignment of the property, everything is
fine, even with the property defined. This out of memory error also
occurs if I cut the number of controls to 50 from 100.

Any ideas what is going on??

Terry Brown
Stickman Software
http://www.stickmansoftware.com
 
D

Daniel Moth

This is one of the errors VS2005 will catch at compile time. Change your
property:

Private mRow As Integer

Public Property row() As Integer
Get
Return mRow
End Get
Set(ByVal Value As Integer)
// here you were calling this property rather than the variable
mRow = Value
End Set
End Property

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