None bold in PropertyGrid

Hi,

Does anyone know how to not display bold font in the propertygrid after we have changed properties by code before its visible for the user?
If the user change a value its okey that its shown in bold font.

Rgds Cynkan
cynkanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lordaeonzCommented:
what control did you use? are you using a data grid or what, can you paste some of your code so we can take a look and maybe figure something
0
cynkanAuthor Commented:
The control we want to clear the changed bold font for is a Infragistics button that we modified and inherit in our our own buttonclass but this behaviour is the same for all controls that the propertybag are connected to. When we connect our button to the propertybag all properties that we change are in bold and this looks ugly...
If you change a property in propertybag connected for any control, the font gets bold for the changed property. What we want is a method that clear this bold font for all properties.
 
0
cynkanAuthor Commented:
Clearify, its a System.Windows.Forms.PropertyGrid control that shows properties for another control I am talking about
 
0
VandG10Commented:
As you know, PropertyGrid marks in bold any value different from default. So, you solution is to specify you desired value as default for each required property.

Two possible solutions for this:
- First is usefull in case you object has static default value, that shouldn't be changed by runtime.
In this case you can simply specify default value by attribute at object property. For example:

public class Car
{
    public Car()
    {
    }

    [CategoryAttribute("Main group"), DescriptionAttribute("Number of passengers"), DefaultValue(4)]
    public int NumberOfPassengers { get; set; }
    ......
}

- Second is useful in case you need to set default values at runtime based on object instance. In this case you SHOULD NOT apply DefaultValueAttribute for the property. Insteed of this you need to provide additional public property to store your runtime value and in addition you need add public function named in following format ShouldSerializeXXX. XXX - is relative property name. For example:

[DefaultPropertyAttribute("Brand")]
public class Car
{
    public Car()
    {
    }

    [Browsable(false)]
    public int DefaultNumberOfPassengers { get; set; }
    public bool ShouldSerializeNumberOfPassengers() { return NumberOfPassengers != DefaultNumberOfPassengers; }

    [CategoryAttribute("Main group"), DescriptionAttribute("Number of passengers")]
    public int NumberOfPassengers { get; set; }
    .........
}

This class can be used from your code on runtime in following way:

{
      Car car = new Car();
      ...........
      car.NumberOfPassengers = 4;
      ...........
      car.DefaultNumberOfPassengers = 4;

      propertyGrid1.SelectedObject = car;
}

As you see, both NumberOfPassengers  and DefaultNumberOfPassengers  set to 4, so after initialization this value willn't be marked as bold.

Hope this help,
V&G
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cynkanAuthor Commented:
Back from eastern, sorry for the delay of response.
Okey then I understand how to use this. Should not be to hard to implement. Many thanks for assistance.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.