Click here to Skip to main content
14,689,511 members
Home » Discussions » C#
   

C#

 
GeneralRe: How to go to the next color? Pin
DaveyM691-Aug-08 4:42
professionalDaveyM691-Aug-08 4:42 
AnswerRe: How to go to the next color? Pin
Frank Horn30-Jul-08 5:44
MemberFrank Horn30-Jul-08 5:44 
GeneralRe: How to go to the next color? Pin
bouli31-Jul-08 0:07
Memberbouli31-Jul-08 0:07 
QuestionProperty Attributes Pin
cecildt30-Jul-08 1:49
Membercecildt30-Jul-08 1:49 
AnswerRe: Property Attributes Pin
Tuwing.Sabado30-Jul-08 4:36
MemberTuwing.Sabado30-Jul-08 4:36 
GeneralRe: Property Attributes Pin
cecildt30-Jul-08 4:52
Membercecildt30-Jul-08 4:52 
GeneralRe: Property Attributes Pin
Tuwing.Sabado30-Jul-08 5:10
MemberTuwing.Sabado30-Jul-08 5:10 
AnswerRe: Property Attributes Pin
Wendelius30-Jul-08 9:46
mveWendelius30-Jul-08 9: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 11:19
Membercecildt30-Jul-08 11:19 
GeneralRe: Property Attributes Pin
Wendelius30-Jul-08 11:23
mveWendelius30-Jul-08 11:23 
QuestionDirect3D Wrapper - C# or Managed C++ ? Pin
Kel_30-Jul-08 1:44
MemberKel_30-Jul-08 1:44 
AnswerRe: Direct3D Wrapper - C# or Managed C++ ? Pin
Simon P Stevens30-Jul-08 1:53
MemberSimon P Stevens30-Jul-08 1:53 
AnswerRe: Direct3D Wrapper - C# or Managed C++ ? Pin
User 665830-Jul-08 2:11
MemberUser 665830-Jul-08 2:11 
AnswerRe: Direct3D Wrapper - C# or Managed C++ ? Pin
Kel_30-Jul-08 10:59
MemberKel_30-Jul-08 10:59 
AnswerRe: Direct3D Wrapper - C# or Managed C++ ? Pin
Mark Churchill30-Jul-08 18:05
MemberMark Churchill30-Jul-08 18:05 
AnswerRe: Direct3D Wrapper - C# or Managed C++ ? Pin
Kel_1-Aug-08 4:48
MemberKel_1-Aug-08 4:48 
Questioncrystal reports with dynamic column display Pin
sarilee30-Jul-08 1:33
Membersarilee30-Jul-08 1:33 
Questionversion Pin
arkiboys30-Jul-08 1:20
Memberarkiboys30-Jul-08 1:20 
AnswerRe: version Pin
DaveyM6930-Jul-08 2:02
professionalDaveyM6930-Jul-08 2:02 
GeneralRe: version Pin
arkiboys30-Jul-08 3:25
Memberarkiboys30-Jul-08 3:25 
QuestionIn which event i can read the access card [modified] Pin
V K Gupta30-Jul-08 1:16
MemberV K Gupta30-Jul-08 1:16 
AnswerRe: In which event i can read the access card Pin
stancrm30-Jul-08 1:52
Memberstancrm30-Jul-08 1:52 
GeneralRe: In which event i can read the access card Pin
V K Gupta30-Jul-08 3:37
MemberV K Gupta30-Jul-08 3:37 
GeneralRe: In which event i can read the access card Pin
carbon_golem30-Jul-08 3:47
Membercarbon_golem30-Jul-08 3:47 
QuestionConverting Dataview to a Datatable. Pin
salmonraju30-Jul-08 1:15
Membersalmonraju30-Jul-08 1: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.