Showing posts with label Telerik. Show all posts
Showing posts with label Telerik. Show all posts

August 01, 2012

Visual Studio; The Document outline window

I really love Telerik controls especially in a winforms and environment. In a windows form solution it gives you this visual edge where your apps just looks a little more professional and appealing. RadDock is by far my most favorite control, closely followed by RadCommandBar.

My problem

Okay, so Telerik did a great job with those winform controls. But the problem is the order I drag my controls from the toolbox to my form. Usually I add a RadCommandBar first docking it to the top of the form, followed by a RadDock docking the form. Occasionally I first add the dock then the bar, resulting in the bar overlaying the dock.

Not the desired end result...

Problem solved?

Sort of... Usually I went to the forms designer code behind and changed the Me.Controls.Add order.

Problem Solved!

But by chance I stumbled into a Visual Studio feature which is far more easy: The document outline window! A -almost "hidden"- window showing all controls on your form. Rearranging controls is reduced to drag'n'drop and clicking arrows. No more need to edit designer code behind.

To show this window from the main menu, select View -> Other Windows -> Document Outline

July 13, 2012

Generated objects, property exists? (or not!)

The ORM of choice of my employer is Telerik Open Access. It supports both forward and reverse mapping. When doing SCRUM development, it gives us the flexibility to quickly add some database columns, tables, foreign key relations etc. in the database and then generate the business objects in our data layer.

My problem

In a particular project the customer opted for record tracking. Who -and when- created (e.g.) a person in the database, and who (when) had it changed.
The catch though:
  • it's not required for all tables. 
  • The creation / modification user is only known in the software (no database trigger solution).

Problem solved?

One part of the solution was to edit the Telerik Open Access class generation templates. In those templates we added a (default!) constructor. In the constructor we set the creator and creation date properties. Adding / implementing INotifyPropertyChanged handled the modification properties. The generation of the business classes was no problem, but compiling the project was another story...
Not every business class had the creation properties, so we faced "some" compiler errors.

Problem solved!

Refelection saved the day. Instead of setting the property straight forward in the constructor:
 this._createUser="new creator";  
it's 'decorated' with an if:
 if(!this.GetType().GetProperty("CreateUser") == null)  
   this.GetType().GetProperty("CreateUser").SetValue(this,"new creator",null);  

Now we can (re-)generate the class model without the headache of modifying 70+ constructors for objects without tracking (or the need to add 40+ constructers  when not generated).