Debugging - how to track a button visibility change and stop programexecution

  • Thread starter Thread starter GiJeet
  • Start date Start date
G

GiJeet

I put the the button property in the watch window but it doesn't stop
when the property changes value. For example I put
this.myButton.Visible in the watch window with an initial value of
false and I want program execution to stop when the Visible property
changes to true. how to accomplish this?

TIA
G
 
GiJeet said:
I put the the button property in the watch window but it doesn't stop
when the property changes value. For example I put
this.myButton.Visible in the watch window with an initial value of
false and I want program execution to stop when the Visible property
changes to true. how to accomplish this?

TIA
G

Eh,

Are you talking about an advanced breakpoint functionality? The watch
window doesn't cause breakpoints to happen, and unless your program is inside
a breakpoint the watch window is disabled.

If your goal is to break into the program when a button's visibility
property is set to true or false you have several options.

Using Visual Studio 2008 you can download the source code for
System.Windows.Forms.dll and set a breakpoint on the Control.Visible property
(or some code called by this property as I had code mismatch and had to set
the breakpoint on SetVisibleCore). For instructions on how to download
framework source read these articles:

[How to: Debug .NET Framework Source]
http://msdn.microsoft.com/en-us/library/cc667410.aspx

[Configuring Visual Studio to Debug .NET Framework Source Code]
http://blogs.msdn.com/sburke/archiv...tudio-to-debug-net-framework-source-code.aspx

You can also create your own Button and create a Visible property on it. As
long as you call this property as a <YourButton> reference you can set a
breakpoint in it.

class MyButton : Button
{
public new bool Visible
{
get { return base.Visible; }
set { base.Visible = value; }
}
}

You can databind the Visible property on the Button to a property of your
own and set a breakpoint on the property setter.


button1.DataBindings.Add("Visible", this, "SomeProperty", false,
DataSourceUpdateMode.OnPropertyChanged);

....

private bool _someProperty;
public bool SomeProperty
{
get { return _someProperty; }
set { _someProperty = value; }
}
 
I put the the button property in the watch window but it doesn't stop
when the property changes value. For example I put
this.myButton.Visible in the watch window with an initial value of
false and I want program execution to stop when the Visible property
changes to true. how to accomplish this?

If you're looking for the VB6 functionality of "break when this value
changes," you can forget about it. The .NET IDEs don't have the same
concept. You have to put breakpoints anywhere the value might change. Your
first thought is probably "Why did they remove this?! It was so handy!" I
agree, I agree.
 
If you're looking for the VB6 functionality of "break when this value
changes," you can forget about it. The .NET IDEs don't have the same
concept. You have to put breakpoints anywhere the value might change. Your
first thought is probably "Why did they remove this?! It was so handy!" I
agree, I agree.

Yes that's what I was looking for. Hmmm.... the whole point of
tracking when something chages is...YOU DON'T KNOW WHEN IT CHANGED AND
YOU ARE TRYING TO FIND THAT POINT IN THE CODE. This is a real
setback....
 
Back
Top