Click here to Skip to main content
15,895,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to go to the next color? Pin
DaveyM691-Aug-08 3:42
professionalDaveyM691-Aug-08 3:42 
AnswerRe: How to go to the next color? Pin
Frank Horn30-Jul-08 4:44
Frank Horn30-Jul-08 4:44 
GeneralRe: How to go to the next color? Pin
bouli30-Jul-08 23:07
bouli30-Jul-08 23:07 
QuestionProperty Attributes Pin
cecildt30-Jul-08 0:49
cecildt30-Jul-08 0:49 
AnswerRe: Property Attributes Pin
Tuwing.Sabado30-Jul-08 3:36
Tuwing.Sabado30-Jul-08 3:36 
GeneralRe: Property Attributes Pin
cecildt30-Jul-08 3:52
cecildt30-Jul-08 3:52 
GeneralRe: Property Attributes Pin
Tuwing.Sabado30-Jul-08 4:10
Tuwing.Sabado30-Jul-08 4:10 
AnswerRe: Property Attributes Pin
Wendelius30-Jul-08 8:46
mentorWendelius30-Jul-08 8:46 
Hi,

The best solution for you depends on many things such as which controls are you using, are you building your own controls, shold the display values depend on the data etc.

Few possibilities you could consider:
1. You could add properties to your class which tell the preferred size of a control that display the property. For example:
public class Client {
   public string Name { get; set;}
   public string Email { get; set;}
   public System.Drawing.Size PreferredSizeForName {
      get {
         return new System.Drawing.Size(35, 13);
      }
   }
}

After that you can bind the size of a control to that property using advanced bindings or code

2. Use custom attributes. Derive your own attribute from System.Attribute and use reflection in your code to see what is the preferred size and then adjust your own control by that value. For example:
[System.AttributeUsage(AttributeTargets.Property)]
public class PreferredSizeAttribute : System.Attribute {
   private int _width;
   private int _height;

   public PreferredSizeAttribute(int width, int height) {
      this._width = width;
      this._height = height;
   }

   public int Width {
      get {
         return this._width;
      }
      set {
         this._width = value;
      }
   }
   public int Height {
      get {
         return this._height;
      }
      set {
         this._height = value;
      }
   }
   public System.Drawing.Size Size {
      get {
         return new System.Drawing.Size(this.Width, this.Height);
      }
   }
}

and then usage:
public class Client {
   private string name;
   [PreferredSize(35, 13)]
   public string Name {
      get {
         return name;
      }
      set {
         name = value;
      }
   }
   public string Email { get; set;}
}

Refer to documentation how to check the existence of an attribute and get it's values.

Hope this helps,

Mika
GeneralRe: Property Attributes Pin
cecildt30-Jul-08 10:19
cecildt30-Jul-08 10:19 
GeneralRe: Property Attributes Pin
Wendelius30-Jul-08 10:23
mentorWendelius30-Jul-08 10:23 
QuestionDirect3D Wrapper - C# or Managed C++ ? Pin
Kel_30-Jul-08 0:44
Kel_30-Jul-08 0:44 
AnswerRe: Direct3D Wrapper - C# or Managed C++ ? Pin
Simon P Stevens30-Jul-08 0:53
Simon P Stevens30-Jul-08 0:53 
AnswerRe: Direct3D Wrapper - C# or Managed C++ ? Pin
User 665830-Jul-08 1:11
User 665830-Jul-08 1:11 
AnswerRe: Direct3D Wrapper - C# or Managed C++ ? Pin
Kel_30-Jul-08 9:59
Kel_30-Jul-08 9:59 
AnswerRe: Direct3D Wrapper - C# or Managed C++ ? Pin
Mark Churchill30-Jul-08 17:05
Mark Churchill30-Jul-08 17:05 
AnswerRe: Direct3D Wrapper - C# or Managed C++ ? Pin
Kel_1-Aug-08 3:48
Kel_1-Aug-08 3:48 
Questioncrystal reports with dynamic column display Pin
sarilee30-Jul-08 0:33
sarilee30-Jul-08 0:33 
Questionversion Pin
arkiboys30-Jul-08 0:20
arkiboys30-Jul-08 0:20 
AnswerRe: version Pin
DaveyM6930-Jul-08 1:02
professionalDaveyM6930-Jul-08 1:02 
GeneralRe: version Pin
arkiboys30-Jul-08 2:25
arkiboys30-Jul-08 2:25 
QuestionIn which event i can read the access card [modified] Pin
V K Gupta30-Jul-08 0:16
V K Gupta30-Jul-08 0:16 
AnswerRe: In which event i can read the access card Pin
stancrm30-Jul-08 0:52
stancrm30-Jul-08 0:52 
GeneralRe: In which event i can read the access card Pin
V K Gupta30-Jul-08 2:37
V K Gupta30-Jul-08 2:37 
GeneralRe: In which event i can read the access card Pin
carbon_golem30-Jul-08 2:47
carbon_golem30-Jul-08 2:47 
QuestionConverting Dataview to a Datatable. Pin
salmonraju30-Jul-08 0:15
salmonraju30-Jul-08 0:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.