B
BoloBaby
I have an extremely vexing problem occurring in a program that I am writing.
Consider the following block of code:
Dim pDancer As New BEDancer
mintIndex = mintIndex + 1
pDancer.DancerName = "Dancer #" & mintIndex
pDancer.DancerStatus = BEDancerStatus.BE_AVAILABLE
pDancer.CardID = mintIndex
oBEDancerList.AddDancer(pDancer)
....where BEDancer is a user defined class in a referenced class library,
mintIndex is a class level variable, and oBEDancerList is a user control
defined in a referenced control library.
When I place this code (and only this code) into the event handler for the
click event of a button on a form, it executes flawlessly - the BEDancer
gets added to the BEDancerList control without any complications.
HOWEVER...
When I place this code (and only this code) into the event handler for the
"CardInserted" event in a user defined class (which is instantiated in the
code for the form), the code executes up to the line "pDancer.CardID =
mintIndex" and NO FURTHER. Beyond that, the code simply STOPS EXECUTING.
If I place additional code after the AddDancer method, it doesn't execute.
No errors are thrown - it just stops. If I comment out the
"oBEDancerList.AddDancer(pDancer)" line, code past it will execute just
fine.
Why would this block of code work fine for a click event but not for the
event raised by my custom class? The custom class does not reference the
BEDancerList control library in any way. It uses the BEDancer class from a
shared class library. In fact, the files look like this:
BEGlobals.dll <- location of BEDancer
BEControls.dll <- location of BEDancerList control
BELib.dll <- location of the class which raises the "CardInserted" event
BEDJApp.exe <- main app that is running it all
The latter three files all reference BEGlobals.dll, if that matters.
Finally, I can still access the oBEDancerList control from the
"CardInserted" event handler. I can display the oBEDancerList.DancerCount
property or even call the oBEDancerList.RemoveDancer method. I just can't
AddDancer! Very, very troublesome indeed.
In case you want to see this, the AddDancer code looks like this:
Dim pDancerBox As BEDancerBox
pDancerBox = New BEDancerBox(Dancer)
AddHandler pDancerBox.Clicked, AddressOf DancerBoxClicked
AddHandler pDancerBox.StatusChanged, AddressOf StatusChanged
pnlDancerList.Controls.Add(pDancerBox)
Reorder(pnlDancerList.Controls.Count - 1)
I tried commenting out the AddHandler lines in case something funky was
going on there, but that didn't make any difference. As you may be able to
tell from this code, the AddDancer method is adding BEDancerBox controls
into a panel control.
Any thoughts?
(Oh yeah - as you may be able to tell, this is an application for a... uh...
"gentlemen's club." If you can help - and are local - I can probably hook
you up with a free couch dance! LOL! ;-))
Consider the following block of code:
Dim pDancer As New BEDancer
mintIndex = mintIndex + 1
pDancer.DancerName = "Dancer #" & mintIndex
pDancer.DancerStatus = BEDancerStatus.BE_AVAILABLE
pDancer.CardID = mintIndex
oBEDancerList.AddDancer(pDancer)
....where BEDancer is a user defined class in a referenced class library,
mintIndex is a class level variable, and oBEDancerList is a user control
defined in a referenced control library.
When I place this code (and only this code) into the event handler for the
click event of a button on a form, it executes flawlessly - the BEDancer
gets added to the BEDancerList control without any complications.
HOWEVER...
When I place this code (and only this code) into the event handler for the
"CardInserted" event in a user defined class (which is instantiated in the
code for the form), the code executes up to the line "pDancer.CardID =
mintIndex" and NO FURTHER. Beyond that, the code simply STOPS EXECUTING.
If I place additional code after the AddDancer method, it doesn't execute.
No errors are thrown - it just stops. If I comment out the
"oBEDancerList.AddDancer(pDancer)" line, code past it will execute just
fine.
Why would this block of code work fine for a click event but not for the
event raised by my custom class? The custom class does not reference the
BEDancerList control library in any way. It uses the BEDancer class from a
shared class library. In fact, the files look like this:
BEGlobals.dll <- location of BEDancer
BEControls.dll <- location of BEDancerList control
BELib.dll <- location of the class which raises the "CardInserted" event
BEDJApp.exe <- main app that is running it all
The latter three files all reference BEGlobals.dll, if that matters.
Finally, I can still access the oBEDancerList control from the
"CardInserted" event handler. I can display the oBEDancerList.DancerCount
property or even call the oBEDancerList.RemoveDancer method. I just can't
AddDancer! Very, very troublesome indeed.
In case you want to see this, the AddDancer code looks like this:
Dim pDancerBox As BEDancerBox
pDancerBox = New BEDancerBox(Dancer)
AddHandler pDancerBox.Clicked, AddressOf DancerBoxClicked
AddHandler pDancerBox.StatusChanged, AddressOf StatusChanged
pnlDancerList.Controls.Add(pDancerBox)
Reorder(pnlDancerList.Controls.Count - 1)
I tried commenting out the AddHandler lines in case something funky was
going on there, but that didn't make any difference. As you may be able to
tell from this code, the AddDancer method is adding BEDancerBox controls
into a panel control.
Any thoughts?
(Oh yeah - as you may be able to tell, this is an application for a... uh...
"gentlemen's club." If you can help - and are local - I can probably hook
you up with a free couch dance! LOL! ;-))