PC Review


Reply
Thread Tools Rate Thread

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

 
 
GiJeet
Guest
Posts: n/a
 
      27th Oct 2008
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
 
Reply With Quote
 
 
 
 
Morten Wennevik [C# MVP]
Guest
Posts: n/a
 
      28th Oct 2008

"GiJeet" wrote:

> 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/archive...urce-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; }
}



--
Happy Coding!
Morten Wennevik [C# MVP]
 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      28th Oct 2008
"GiJeet" <(E-Mail Removed)> wrote in message
news:232fc87d-3b8d-4f78-93d8-(E-Mail Removed)...

>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.


 
Reply With Quote
 
GiJeet
Guest
Posts: n/a
 
      3rd Nov 2008
>On Oct 28, 9:41*am, "Jeff Johnson" <i....@enough.spam> wrote:
> 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....

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to stop focus change on button click colin Microsoft C# .NET 2 4th Dec 2007 02:01 AM
Set button Visibility =?Utf-8?B?UmlwcGVy?= Microsoft Access Form Coding 2 28th Jun 2007 02:32 AM
How to stop template worksheet visibility leaftye - ExcelForums.com Microsoft Excel Programming 4 16th Aug 2005 08:07 PM
change visibility of a button from an assembly TJS Microsoft ASP .NET 0 15th Jun 2005 07:43 AM
Change button visibility in run time =?Utf-8?B?QnJ5bg==?= Microsoft Access 1 11th May 2005 05:26 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:49 PM.