Wednesday, March 10, 2010

A useful post for Telerik Users?

Well I found out, that these Telerik WinControls are boon and bane. I like theme because I do a lot of great design stuff via XML and Themes. And if you know what you’re doing these controls really perform. But I ran into a System.StackoverflowException and I found the documentation on that specific error very helpful. So thx anyway Microsoft. If I wouldn’t knew it anyway - what caused that error - I guess I would be lost. Take a moment, before they change the documentation on this error, I make a screenshot.

image

I like the explanation part.

image

Saying: A StackOverflowException occurs when the Stack overflows. Yes, who’d a thunk? Or WTF? So guys what happened here?

Well looks like the beloved Telerik.RadComboBox had a little event handling problem calling the Data Source. Since it's a bindingproblem within the RadControl there is no way for me changing that. Since the Data comes from a Service i also had no chance to edit that. Anyway debugging that is not easy. Found a cool article on this topic. Where? Yes, at stackoverflow.com! Since I have a modular software and want to fill the items of the comboBox by a public data Method and some parts at the control itself, it turns out the question: “How can I do that?”

So first I make sure evrything works fine when the controls are called. And check if the data source is null. In my example I want to bind the German tax authorities to that Combobox.

  private void InitMyComboBox()
 {
   ...
   if (comboBoxTaxAuthority.DataSource == null)
       comboBoxTaxAuthority.DataSource =
                            Logic.GetTaxAuthorities();
   ...
 }

“Logic” is a Mapper which points me as you might think to a static implementation of a Singleton which loads that data from a service.

Next step is to implement the ItemDataBound event.

private void ComboBoxTaxAuthorityItemDataBound(object sender, ItemDataBoundEventArgs e)
{
   var item = e.DataBoundItem as RadComboBoxItem;
   if (item != null)
   {
     var x = e.DataItem as TaxAuthority;
     if (x!=null)
     {
       item.Value = x;
       item.Text = x.Name;
       item.DescriptionText = "Finanzamt " + x.Name;
       item.Image = Properties.Resources.authorities;
       item.TextImageRelation =
                     TextImageRelation.ImageBeforeText;
      }
    }
}

So what this does, it casts the DataBoundItem which I get from the method to a RadComboBoxItem so that I can manipulate it at design time and set the things how they should be displayed. in the next step I set the properties. For example I want to set the Text and Value of the new item to it’s inner DataBoundItem properties. And then I can set the Image from the Resource file to appear in the ComboBox. The last thing to do is to set the Image Text relation of the object. So this is the way how I solved the problem with the databinding and image from a resource file. Doing it by hand however is not the fastest way but i get rid of that stupid exception. It would take much longer to show the code which caused that error. Because the hole class is about 150.000 Lines of code. To cut the edges I just wanna mention 2 things. First: Don’t program Event Driven. The idea of event driven development is totally wrong when you interact with nearly any sort of communication or data interaction. Think about the latency between “Event is fired” and “the whole Data is loaded and send to the control”. You can call that Message Driven. So thinking "message driven" instead of "event driven" helps you understanding how the system works. Get rid of the PEBKAC (problem exist between keyboard and chair) So disable your controls while waiting for the Message! The result looks like that:

image

So i just have to do the Error Providers and the localization stuff, and yes the Description Text should be reviewed.

Jen, this is the Internet!

image

So i wrote earlier about the Browser Issue. A Browser I've never recognized, is Safari. So i recently did a project for Mac Users. And guess what i had to develop that app for the Mac. Since my Objective C couldn’t be better i used Quartz Composer. OMG what a hell of a hack. This is like drawing with numbers. I couldn’t think of a easier and at the same time … way of developing. I learned what marketing drew really means. Yes it runs anyway. But i had to use the Safari Browser. And guess what i installed him on my Windows Clients as well. OMG why is this browser so fast. Since I already have bunch of browsers running on my system i guess it's time to add another one. But what i wanted to say is: Browsing is fun, and fast. I like that. What, why did i mentioned that? i learned another thing today. Kids aren’t small people, they are only stupid. That's all they are. And since i listen to a Canadian Internet radio station I'm really getting childish. Did you heard that news? Don't listen to that shit!

Anyway as my new favorite internet radio station discusses that issue, I found it killingly funny. I really get a new picture of Canadians due to the Olympic games. And just wanted to mention that it’s funny to laugh together about ... Hell of hack, oh lords how should I lead or point over to the it-crowd header of that posting?  I have no clue maybe because I'm so childish or is it the new browser. If I will ever come up with a conclusion, i let you know. In the meanwhile I for myself will continue listen to The Beat and keep on coding. Just needed a break; cw(thx);