473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Binding to visible property - is this a bug?

Hi,
I have a couple of labels on a form and their visible property is bound
to boolean properties on a custom object. When I first load the form, all
works as it should. This form is 'tied' together with a search form, and the
user can go back and forth. When the user hits ok, the form is hidden and
the search form is shown and visa-versa. The problem is that when the form
is hidden when the labels visible property is False, and then shown again
with an object that should cause one or more of them to be visible, they are
not! It seems that the framework decides at 'show' time that since the label
is not visible, it no longer has to 'obey' the binding rules for it. This
seems like a bug to me. Of course I can get around the problem by setting
both labels visible property to true in the forms activated event, right
before I bind the newly selected object to the bindidng source. But again,
why are the binding rules changing at show time, they should of been 'fixed'
at load time!
--
Terry
Dec 20 '07 #1
5 3924
Hi Terry,

Firstly, make sure that the Visible property of the Label is set to true
before it is bound to the custom object.

If a control is not visible before it is bound to a data source, the data
binding won't push data from the data source into the control. This is a by
design behavior.

Secondly, you need implement the INotifyPropertyChanged interface for the
custom object, so that when the values of the properties in the custom
object change, the bound control will reflect the change immediately.

The following is a sample:

using System.ComponentModel;

public class Address:INotifyPropertyChanged
{
bool visible;
public bool Visible
{
get { return visible; }
set
{
if (visible != value)
{
visible = value;
OnPropertyChanged("Visible");
}
}
}

public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new
PropertyChangedEventArgs(propertyName));
}
}
}

Please try my suggestion to see if the problem is solved and let me know
the result.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 21 '07 #2
Hi Linda and thanks for the responce - even if it was in C#! lol

Not sure you understand what I am trying to say. The program works fine if
I never hide it and then show it again. If I switch the datasource (for the
bindingsource) the visible properties all work ok. I can go from one that
has them 'off' to one that has them 'on' and visa-versa and all is ok. But
if I hide the form while they are 'off' and then reshow the form - it no
longer works. And my question is why? To me, hiding and re-showing a form
should not change the behavior of the form! It is like the framework is
re-evaluating the binding rules at the time the form is (re)shown - which
does not make sense to me.
--
Terry
"Linda Liu[MSFT]" wrote:
Hi Terry,

Firstly, make sure that the Visible property of the Label is set to true
before it is bound to the custom object.

If a control is not visible before it is bound to a data source, the data
binding won't push data from the data source into the control. This is a by
design behavior.

Secondly, you need implement the INotifyPropertyChanged interface for the
custom object, so that when the values of the properties in the custom
object change, the bound control will reflect the change immediately.

The following is a sample:

using System.ComponentModel;

public class Address:INotifyPropertyChanged
{
bool visible;
public bool Visible
{
get { return visible; }
set
{
if (visible != value)
{
visible = value;
OnPropertyChanged("Visible");
}
}
}

public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new
PropertyChangedEventArgs(propertyName));
}
}
}

Please try my suggestion to see if the problem is solved and let me know
the result.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 21 '07 #3
Hi Again,
Well I just tried to duplicate my problem on a much smaller scale and
could not. So it is obvious that I have something else going on here and I
don't want you to waste anymore of your time till I get this a little more
sorted out. The complexity that I am dealing with is that I am sharing
bindingsources between forms which may be where the problem lies. I will get
back to you when I get clearer on the issue.
Thanks again,
--
Terry
"Linda Liu[MSFT]" wrote:
Hi Terry,

Firstly, make sure that the Visible property of the Label is set to true
before it is bound to the custom object.

If a control is not visible before it is bound to a data source, the data
binding won't push data from the data source into the control. This is a by
design behavior.

Secondly, you need implement the INotifyPropertyChanged interface for the
custom object, so that when the values of the properties in the custom
object change, the bound control will reflect the change immediately.

The following is a sample:

using System.ComponentModel;

public class Address:INotifyPropertyChanged
{
bool visible;
public bool Visible
{
get { return visible; }
set
{
if (visible != value)
{
visible = value;
OnPropertyChanged("Visible");
}
}
}

public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new
PropertyChangedEventArgs(propertyName));
}
}
}

Please try my suggestion to see if the problem is solved and let me know
the result.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 21 '07 #4
Hi Terry,

Thank you for your reply!

I look forward to your further information on this issue.

If you could reproduce the problem in a simple project, please send it to
my email box. Remove 'Online' from my displayed email address to get my
actual email address.

Happy New Year!

Sincerely,
Linda Liu
Microsoft Online Community Support

Dec 25 '07 #5
For anyone who might be having a similar problem - this is a bug. It turns
out that whenever you show/re-show a form who's Mdi-parent property has been
set, the binding context is re-set, and any control currently not visible
(even though the visibility property is bound) has it's IsBinding property
set to False and never properly binds again in the future.
--
Terry
"Terry" wrote:
Hi,
I have a couple of labels on a form and their visible property is bound
to boolean properties on a custom object. When I first load the form, all
works as it should. This form is 'tied' together with a search form, and the
user can go back and forth. When the user hits ok, the form is hidden and
the search form is shown and visa-versa. The problem is that when the form
is hidden when the labels visible property is False, and then shown again
with an object that should cause one or more of them to be visible, they are
not! It seems that the framework decides at 'show' time that since the label
is not visible, it no longer has to 'obey' the binding rules for it. This
seems like a bug to me. Of course I can get around the problem by setting
both labels visible property to true in the forms activated event, right
before I bind the newly selected object to the bindidng source. But again,
why are the binding rules changing at show time, they should of been 'fixed'
at load time!
--
Terry
Jan 11 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mike | last post by:
Hi, I'd like advice from a .NETer. I have a loadcombo routine which sets the selectedindex to -1 if it's an "add record", but then it goes to a security routine which, based on permissions...
5
by: Lucvdv | last post by:
Can anyone explain why this happens with the code at the bottom? It looked like a thread safety issue, but changing the declaration of Label1 to Shared doesn't help. Standard windows form;...
6
by: Marc Robitaille | last post by:
Hello, Hello, I developed a UserControl. It has funny behavior. It is composed of three controls. A texbox, a combobox and a button. There are three properties to indicate the visibility of...
6
by: Robert | last post by:
Quick question about the visible property on a form control. I have a label that displays a message if a certain criteria is met. By default the label is visible. I want access to compare a...
2
by: Keithb | last post by:
I need to hide a GridView's "edit" column if the user's role does not support editing. However, the column's Visible property does not support databinding. Is there a workaround? Thanks, ...
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
3
by: Mark B | last post by:
I have a gridview that contains a linkButton in a template field. I want to set the visibility of the linkbutton based on a bit field in a database. Selecting the proper field in editbindings...
5
by: Doogie | last post by:
Hi, I am trying to access the visible property of an ASP button inside javascript to no avail. Here's what my button control looks like: <asp:Button id="btnAcceptTrips" name="btnAcceptTrips"...
8
by: Doc John | last post by:
I have an MDI container with a child Form which will be visible according to certain events. The problem is that when I set the property Visible to False and then back to True, the Form will be in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.