Friday, June 29, 2012

Telerik RadGridView Hierarchical Data (Child Grids) for Winforms Gotcha

The Gripe
I have been banging my head against a wall since yesterday trying to figure out what the hell I was doing wrong with my RadGridView's Hierarchical Child Grid. I configured it, re-configured it, blew it away, did it again. I got it working, then it randomly stopped working. I was quite livid at this point, so I called it a day and figured I would leave this problem for today.

Well today came around and I found the problem. I am calling this a bug and a gigantic fuck you Gotcha from Telerik. So this is obviously not intentional behavior, it is a bug, but this bug just wasted almost two whole work days for me to figure out. I thought I was doing something wrong and the whole time it turns out my configuration was fine, it is the control itself that is flawed.

Here are relatively clear instructions from Telerik on how to create GridViews with Hierarchical Child Grids:
http://www.telerik.com/help/winforms/gridview-hierarchical-grid-tutorial-binding-to-hierarchical-data.html

I am thinking about re-doing the article on my blog for actual objects and not DataSets, because let's face it, no offense, but if you are using DataSets directly with your grid you are probably doing something wrong. That isn't a clean or safe approach.

The Gotcha
If you followed all of the instructions as described in the above link and you are 100% sure that you did everything correctly then here is the gotcha:

If you click directly on the + sign of the row, you will not see any child rows!

The Work Around
You MUST click on the row itself first to make it active, THEN you can click on the + sign to show the child rows.

I don't understand why this is happening, but it does. Here are screen shots of what I am talking about, I can reproduce this behavior, so this isn't a baseless complaint:




How am I supposed to explain to users that this is how it works? This is a bug plain and simple. The moment a user experiences something like this I would get an phone call or email complaining about it.

I am not sure if this is fixed in the latest version of Telerik, but for the record I am using "RadControls for WinForms Q1 2012 SP1".

Update (07/12/2012) - I upgraded to Winforms Q2 2012, this did not fix the problem.

If I am doing something wrong, reply below and set me straight please.

If I find a solution first I will update this post.

Sunday, June 24, 2012

What to do after rooting your LG C800 T-Mobile myTouch Q

What do I do now?
So I actually did some head scratching after rooting my LG C800 T-Mobile myTouch Q, wasn't really sure what to do. Luckily I found some great posts on what to do that I mentioned in my previous post which sort of got me going. Below I will discuss what I did and provide a list of applications that I Froze or Uninstalled. You can read this article as well, since this is the first thing I read when this question came up.
I've Rooted my Phone now what? What do I Gain from Rooting?

First a Word of Caution...
Don't uninstall or freeze something if you have some serious doubts about what it actually does. Here is how I determined if I was going to Freeze something or not. I asked myself the following:

"Is this an app I have used before or recognize as being bloatware?"
  • If yes then I backed it up and either froze or uninstalled it.
  • If no then I would open the app to see what it was and if it was harmless then I backed it up and uninstalled it. If it was something potentially crucial then I backed it up and froze it.
You want to tread carefully, again if you have any doubts about something that looks very important, then leave it alone or back it up and freeze it, do not uninstall it.

Programs you will Probably Want to Investigate/Install

Super User
After rooting your phone Super User is already installed. You can upgrade to the elite version for $3.00, I did this because I was curious and I feel like I owe them $3.00 for the service that they have provided. Thank's to ChainsDD

Titanium Backup Pro
This program is going to do all of the, as I like to refer to it, the "unfucking" of your phone. It is a great application that will basically allow you to remove or freeze all of the bloatware that is on your phone. It is kind of like opening up msconfig in windows and stopping services and programs from starting, except you can do it on the fly (usually). This program is well worth the money, I say just buy it straight out because you will use it repeatedly. You cannot use this program unless you have rooted your phone because it requires su (super user) access.

Android System Info
This app is fantastic, it shows you all of your current processes. Emphasis on ALL. The stock application manager does not show you jack in comparison, so if you are having a funky problem with your phone, like I am having currently with a random 100% CPU problem for hours at a time, then you want to check this application out. It has a log feature that lets you read the system logs so you can find those culprit processes and try to fix the problem. Found this application mentioned here. Unfortunately the solution mentioned there did not help me, but it might help others, give it a gander.

Usage Timelines Pro
I haven't found a reason to upgrade to pro yet, but this application is essentially a reduced version of Android System Info, except that it has a graphical display of your CPU usage which I find very handy to know when my phone is being stupid. It does not do the same job as Android System Info to display all running processes, it shows you the same thing that your stock application manager shows you which doesn't help much.

What I recommend you should back up and Freeze or Uninstall
  • Please, do not uninstall or freeze any core LG packages. They look like com.lge.*, I couldn't tell you what would happen. I was tempted to freeze a few named com.logmein.*, but again, not sure what that would do to my phone, so I held off.
  • MAKE A BACKUP FIRST of anything you plan on freezing or especially uninstalling
  • I don't know what to do if you freeze or uninstall the wrong thing, just know that, so tread carefully
The T-Mobile Bloatware Shit List (Thank's T-Mobile!)
Most of these are T-Mobile stock apps. The Google+ app isn't obviously, but it was annoying the crap out of me because it would auto start and just sit there and spin for no good reason. I don't like social sites, except twitter which is why you don't see it on the list. That is a personal preference of mine only obviously.

App Name Operation Notes
411 & More Frozen Stock T-Mobile app for 411… no thanks.
Backup Frozen Stock T-Mobile app for backup… no thanks.
CMAS Frozen Stock app for Amber Alerts? Wtf?
Dragon Dictation Frozen This is for your Genius button to work, make sure to read the section below about this.**
Genius Button Frozen This is for your Genius button to work, make sure to read the section below about this.**
Google+ Frozen This program likes to run for no reason and uses 25MB of memory!
Mobile Life Frozen Stock T-Mobile app I will never use
Mobile Life Family Organizer Frozen Stock T-Mobile app I will never use
More for Me Frozen Stock T-Mobile app I will never use
SmartShare Frozen Stock T-Mobile app I will never use
Social+ Frozen Stock T-Mobile app I will never use
T-Mobile Mall Frozen I have the Android Market, why the hell would I want this?
T-Mobile Name ID Frozen Stock T-Mobile app you have to pay to use?
T-Mobile TV Frozen Stock T-Mobile app… No thanks, I have Netflix
TeleNav Frozen Stock T-Mobile app… No thanks, I have Google Navigation
Yelp Uninstall No interest
Zinio Uninstall No interest
Bejeweled Uninstall Game demo, if I want it I will download it
Bonus Apps Uninstall Stock T-Mobile app… more bloatware
Facebook Uninstall If I want this I will download it… I don't want it
Lookout Uninstall Antivirus program, again if I want it I will download it
Slacker Uninstall No interest
Tetris Uninstall Game demo, if I want it I will download it
**Genius Button Warning!
I was very adverse to using this thing because it would crash my phone while I was using it or like 2 hours later, so I got good at not pressing the soft button. That being said, if you freeze this app, if you press the button or long press the button it will CRASH YOUR PHONE and then reboot itself. Ha! So the functionality hasn't changed you see! SO DON'T PRESS THE BUTTON IF YOU FREEZE IT.

Now, if that is too much for you to handle, then you need to find a different solution. I hate that damn button so I would rather my phone crash immediately rather than that stupid death sentence of a program start up and slowly crash my phone for me like terminal cancer.

There are ways to re-route your Genius Button, but I haven't figured it out yet. You can check these links out:
I hope this was useful for anyone looking for it. This rooting stuff is some serious business...

How to root the LG C800 T-Mobile myTouch Q

The Phone
This was quite an adventure and by adventure I mean a humongous painstaking pain in the ass. The actual process is EASY, but the hard part was getting my phone to actually enter debug mode and stay there. I have the LG C800 T-Mobile myTouch Q and the hardware is wonderful, but the OS is crap; no thanks to T-Mobile. The damn thing locks up on me at least 2-3 times a week and trust me when I say I didn't install any odd programs on it. It locked up on me when I just got the phone and I thought it was a fluke, possibly a one time thing, but the phone proved to me I was dead wrong.

The LG C800 T-Mobile myTouch Q would be an excellent phone if it didn't have all this unnecessary crappy bloatware running on it that T-Mobile put there. All the trash on the phone is what makes it crash consistently. I can't tell you how many times I have tried to make a phone call and just watch my phone die as it says "The Process com.android.phone has stopped unexpectedly". It is enough to make you want to throw your phone out of a moving car into a ditch, but of course you remind yourself that you spent $320 on it and that throwing it out of the window would be silly (?)...

Here is a list of issues I have had with my phone:
  1. It locks up when I use it like a phone. This may seem like a pretty simplistic statement, but no seriously I want to make a phone call and it locks up... 
  2. When I am on Bluetooth and I want to make a call while music is playing, it will lock up.
  3. If I press the "Genius" button, after the first use, the phone locks up later.
  4. If I use Google Maps or Google Navigation, the phone will either lockup and die or do me the favor of restarting itself for me so I don't have to.
  5. The phone will start to  sporadically drain its battery for reasons I can't begin to explain. Sometimes it will go on for about a week. This is the most baffling problem of them all. The phone will literally do a Mana burn on its battery for no apparent reason. I can turn of WiFi and Bluetooth, but it will still drain its battery even while it is sitting idle. I have to have the phone plugged in while it is going through this bout of stupidity otherwise the battery goes dead.
All of this made me realize I had to root my phone since unfortunately there are no mods for my phone... Cyanogen does not support this phone and even after numerous requests it seems like they just won't. Oh well... rooting it is better than nothing.

Rooting 101 Gotcha
I won't have any major difference in instructions on how to do this process except a one very important and very stupid gotcha which was the inspiration for this post and that is:

IF YOU ARE DOING THIS ON A PC then make absolutely 100% sure that you have plugged in your phone's USB cable to the BACK of your PC directly to the motherboard and NOT to the front bezel. This caused me 3 hours of pointless head scratching, screaming and googling for why my phone would NOT stay online. My phone kept going offline. It would be alive for about 1 minute then just disappear... This was because I had my cable plugged into the FRONT of my PC as opposed to the BACK of my PC. WHY DOES THIS MATTER? I DON'T KNOOOOWWWWWWW!?$&*(@#$*(&
How I felt when I found out from my friend that plugging the cable into the front bezel doesn't usually work.
I have a vague understanding as to why this matters, but needless to say it does. I can guess that the USB extensions on the front bezel have to travel through a multiplexer of some kind and that can cause the problem (I had some experience working with data and a switching IC, it never worked. I blame the resistance of the IC for that. Same can be said about a multiplexer IC). Either way it is a huge problem and goddamn it - it is annoying. You have been warned.

Basic Instructions on how to Root the LG C800 T-Mobile myTouch Q
Here are the articles I used to figure this out:
Ahttp://thedroidstate.com/how-to-root-lg-mytouch-q-c800-lg-mytouch-4g-e739-easy-tutorial/
Bhttp://www.makeuseof.com/tag/root-android-phone-superoneclick-2/

Article A over simplifies this process to the point where I became paranoid and worried that I might have been missing some important detail.

Article B doesn't do any of what Article A does exactly...

I pretty much did a combination of what both Articles say to do. Since I plan on actually attempting Android development again I went the extra mile and installed everything I would need for that already. According to Article B you require the Android SDK, notice it makes zero mention of that in Article A and I think this is because SuperOneClick (the rooting software) comes with the ADB server already. The SDK just happens to come with the latest ADB server as well.

WTF is an ADB Server?
In short the ADB Server is the process that speaks to your phone, this is crucial for anything to work whether you are rooting, debugging an Android application directly on your phone or debugging your phone period. Think of it as a mediator.

Steps I Took
I strongly recommend reading both articles before proceeding with these steps because a lot of detail is already in those articles and there is no reason for me to repeat it here. These steps are more geared towards developers as it assumes you can figure out the stuff I don't mention or gloss over and these steps prepare you for Android development simultaneously. There are just too many small details, so I am skipping a lot of them because otherwise this would be over 30 steps. If you are not a developer and just want to root your phone straight out, follow Article A and you can still use my post as a guide.
  1. Download SuperOneClick here, but don't run it yet. This is a link to Download.com, the reason is that the official site's link is busted which is silly and I would rather download it from a place like Download.com as opposed to any shady site. You don't want your computer to get a virus or your phone to become a paper weight. After downloading it, unzip it so you can use it later.
  2. Install Java JRE and JDK - if you have a 64 bit system, install both JRE 32 bit and 64bit. Why? Click here for more info. At one point you will need to anyhow because an application may require one versus the other, might as well get it over with now.
  3. Install IntelliJ - I prefer this over Eclipse because it doesn't suck and it now has support for Android, yay.
  4. Install Android SDK 
  5. After the SDK is installed, make sure to install all necessary plugins/packages that you think you will need, not necessarily for the rooting of your phone, just in general. Check Article B for more info.
  6. Get the drivers for your LG C800, unfortunately LG screwed up good and now has three different versions of the LG C800 on their website. I don't understand when this happened, but it did and it is really annoying because NO WHERE on their site will you just find plain old LG C800. There are three versions LGC800DG, LGC800VL and LGC800G. You can ignore the G version, I tried the VL first, but then I ended up using the DG. You only require the drivers and I think, but I am not sure that the drivers should be the same for the DG and VL. In any case I used the DG version. I emailed the fine people over at LG about this problem with my serial number & IMEI number and I asked them which model I had. The fine representative informed me that I had the LGC800... I wanted to hurt the rep very badly...
  7. Backup your phone if you fear for the worst - I did.
  8. Remove your SD Card if you are paranoid - I did.
  9. Enable debug mode and enable the option to keep your screen lit (I am paranoid). Read through Article B for more info.
  10. Plug your phone into the BACK of your PC, laptops should be fine no matter where you plug it in.
  11. Start up IntelliJ.
  12. I could write a whole other post on how to do this, but I won't because it is pretty simple. Create a new project and make sure to set the debugger to point to your phone. Just go through the motions of locating your JDK and Android SDK for IntelliJ to point to. You just want a blank project so you can see the debug output, so don't get hung up on what to call it and where to put it, this is just for the output window. This output will let you know if your phone is alive.
  13. After creating a project. Make sure the ADB Service is running by click on Tools > Android > Enable ADB Service. Why are you making me do this? You are doing this because you want to see all of the un-intelligible debug output in the Logcat window (Actually the output does make sense, it's just that there is a lot of it flying out which makes it cumbersome).
    Enable the ADB Server/Service
    Your phone saying a lot of nonsense...
  14. Let your phone sit for about 5 minutes, if it is still blabbering on and on then you should be good, it doesn't seem like your phone is going to just go offline all of a sudden.
  15. Make sure your phone is charged, even though this process takes like 4 minutes and chances are it is being charged while it is plugged in.
  16. Like mentioned in Article A you want to disable your antivirus on your PC and your phone (I will get to the phone in a moment). I use Microsoft Security Essentials because I am cheap and too lazy to get anything better, not to mention MSE is actually highly regarded as good, so I haven't bothered to get anything better. What am I talking about?
  17. If you are paranoid like me, disable your windows Firewall. I can't explain why, I just did it just because it seemed like one of those things that windows would obstruct at the wrong moment which could destroy my phone. Phone a la Brick.
  18. Supposedly you are supposed to uninstall any Antivirus from your phone... well that is one of the reasons I was rooting my phone, that was not an option for me. Just make sure that any antivirus that you have on your phone is not running as a Device Administrator. To check go to Settings > Location & Security Settings > Select device administrators > Deselect your Antivirus. At this point supposedly you can uninstall it. I tried and it didn't happen. I even tried registering the software and that just made it more annoying by being up on my task bar all of the time. So try, if you can't then meh... didn't seem to matter anyhow. Just make sure it isn't active - as in Actively Protecting your system, disable it if it is running.
  19. Okay... here is where I get a little confused. I don't think this step is necessary, but I did it anyhow. According to Article A you need to:
    C:\adb> adb shell
    $ echo 1 > /data/local/lge_adb.conf
    $ exit
    • After doing this Run SuperOneClick 2.2 and root your device

    So what I did was, instead of using the ADB server that comes with SuperOneClick, I used the server that comes with the Android SDK because it should already be running. So point a command (cmd) window to: C:\Program Files (x86)\Android\android-sdk\platform-tools and do those instructions listed above there. Honestly I don't know what this does (it's just an echo command???), but I did it anyhow because I am paranoid.
  20. Okay so if you did not receive any annoying messages about your phone being offline or the blather from the debug window did not stop and it continues you are good to go to the next step. If your phone did not respond, then you need to figure that out. Use Google because that is what I would do.
  21. Open up SuperOneClick and like Article A and B both say, just click the big ol' "Root" button. Don't do anything while this is happening, just sit and wait. The SuperOneClick window will blurt out a bunch of stuff, seriously just don't touch anything while this is happening. Eventually SuperOneClick will need your attention and tell you everything went smoothly and something about issuing a "su" command (super user). If your phone is still in the process of rebooting, sending that command won't make a different so say yes/no it won't matter if your phone is still in the process of rebooting because it won't receive the command. A point of interest is look at your debugger window while your phone is booting up and watch all of the crap that is loading as it does this. You will/should recognize different program names and other stuff as it starts.
  22. If everything has gone well by this point your phone is rebooting and you can see your phone's desktop again. Congrats the scary part is done.
  23. Turn your computer's Firewall back on and turn your Anti-Virus back on.
  24. Download and install the Pro Version of Titanium Backup on your phone. This is what will allow you to excuse my expletive "un-fuck" your phone with all of the crap that T-Mobile put on there for you as a favor. Thank's T-Mobile. Make sure to do what the program tells you, backup before you freeze or uninstall programs etc...
  25. Use the following links for more help:
    http://android.stackexchange.com/questions/1/ive-rooted-my-phone-now-what-what-do-i-gain-from-rooting
    http://www.makeuseof.com/tag/uninstall-apps-android-phone/
  26. Now you know as much as I do about this spooky process. Wow... this was actually kind of tough.
Great, my phone is rooted. Soooo now what?
Don't worry, this is a common question that even I had. I wrote a whole post on it, just click on this link:

Friday, June 15, 2012

Custom Controls in ToolStrip or StatusStrip

This is not something I have had to deal with too often which is why it wasn't apparent to me the first time around.

FACT: You cannot drag and drop a custom control or any System.Windows.Form.Control onto a System.Windows.Form.StatusStrip or System.Windows.Form.ToolStrip.

Solution
Aha! A gotcha! So how do you fix this problem? Well there are two options:

1. Make your own StatusStrip or ToolStrip item by inheriting from the System.Windows.Forms.ToolStripControlHost class.

Personally I don't like this method because it forces you to make a control that is only good for this purpose.

You can read more about it here.

Frankly I find the name of the article to be very misleading, you aren't really wrapping anything, you are creating a new class that inherits from the ToolStripControlHost. That's like saying making a custom control is a wrapper because it inherits from the Control class. Not so much...

2. Use this handy dandy methodology that apparently has been there all along, but I didn't find out about it until I stumbled across it yesterday during my google search. You simply need to add your custom control programmatically to your ToolStrip or StatusStrip by adding it as a ToolStripControlHost object.

Do Tell...

You simply do the following:
Dim myControl As SomeCustomControl = New SomeCustomControl()

'Perform operations on your control such as size, color, minimum size etc...

ToolStrip1.Items.Add(New ToolStripControlHost(myControl))
'and/or
StatusStrip1.Items.Add(New ToolStripControlHost(myControl))

'If you are working with visbility, you will have to apply it to the ToolStripControlHost as well otherwise your control may not behave.

For the record I got all my info from this post here.

Please note there are sizing issues with this method and I haven't figured them all out yet. So this will require more research to figure out. If and when I figure it out I will be sure to mention it. Just make sure to set the size and the minimum size properties.

Conclusion
I prefer the second option over the first, but there is nothing wrong with the first either. I think that you get more re-usability out of the second option.

Resources
Forum Post about ToolStripControlHost
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/a5813d02-230e-417f-8b6d-cd86585b7f80

How to: Wrap a Windows Forms Control with ToolStripControlHost
http://msdn.microsoft.com/en-us/library/9k5etstz.aspx

Sunday, June 10, 2012

Upgrade/Installing Parcloud Tomato on Asus WL-500gP (Premium) V2

I just had a very bad time upgrading my Asus WL-500gP V2 router to the latest version of Tomato. I made the fatal mistake of uploading the wrong firmware because it is NOT CLEARLY DESCRIBED ON THE SITE. Forgive me for being upset, but is it too much to ask for a simple HTML table describing WHICH download to use for my router!? I shouldn't have to dig so hard for this information... anyhow...

So I ended up bricking my router... yaaaaay. I had that sinking feeling you get when you know you just screwed yourself really bad. Luckily after a few hours of googling and researching I formulated a solution which I am going to share with anyone who wants to read it because this was goddamn ridiculous to figure out:

How to Unbrick Your Asus WL-500gP V2 (Premium) Router after Flashing it with the Wrong Firmware
  1. Download the correct firmware, which for the Asus WL-500gP V2 (Premium) is the ND version. Get it here. Why this is not clearly labeled I don't know! And NO it isn't enough for me to just see that the WL520GU is on the same row and infer that this is the same file that I need for my router. That is called making an assumption which is a foreign concept to me in the world of engineering and computing.
  2. Download the Asus Utility here: http://support.asus.com/download.aspx?SLanguage=en&m=WL-500gP%20V2&p=11&s=2&os=30&hashedid=jTcQKIRXgNPLo54b
  3. Install the Asus Utility and ignore the applications that want to launch at the end of the installation. Those aren't the ones you want to use to fix this problem.  


  4. After the installation you want to run the Firmware Restoration Utility


  5. You will get the following warning, don't ignore it, you want to disable your windows firewall like it asks you to.

  6. Now before you continue you need to prep your brick to become a router again. First things first, disconnect everything from it and plug your computer into one of its LAN ports, not the WAN port. For the record I got these instructions from the dd-wrt website here.
  7. Disconnect the power from your router
  8. Hold down the black restore button
  9. Plug it back in while holding down the restore button and don't let go until the power light starts to flash. It should flash about once a second. If you can't get your router to do this then it might actually be in worse shape than this tutorial can help you with - sorry :(
  10. At this point the router will keep blinking forever until you turn it off (at least this is what I experienced)
  11. Change your computer's IP to 192.168.1.100 (anything but 1)
  12. Change your Subnet to 255.255.255.0
  13. Change your Gateway to 192.168.1.1
  14. Now it is time to cross your fingers
  15. Select the Tomato ND TRX file
  16. Press the Upload button and let it do its thing, don't touch anything, don't think anything, don't breath. Just stare at the screen and hope it gets to the screen that says "Successful" or something like that.

  17. Now if everything went well you aren't pulling your hair out and you see a "Successful" message of some kind, congrats it uploaded.
  18. Wait an additional 2 minutes. Get up, make some coffee, drink it, come back. Just wait the damn 2 minutes, you don't want to thwart your effort thus far.
  19. Change your computer's adapter settings back to Obtain Automatically (IP, Subnet, Gateway, DNS etc...) - you can do this while you are waiting your 2 minutes.
  20. If everything went well then your computer should obtain an IP automatically and you can now jump for joy, you have unbricked your router congrats.
  21. If this didn't work then try power cycling the router, if that doesn't work then I am sorry :(

These are the resources I used to figure all this out:

This was one hell of a gotcha...

Thursday, June 7, 2012

Telerik RadGridView Column Format Calamity

Wow... just wow. I lost about an hour trying to figure out a:
TargetInvocationException: Exception has been thrown by the target of invocation.

This is probably one of the most useless exception messages among others. It really tells you nothing more than, "Something really bad happened when you just did what you did." In my case this exception kept killing my program entirely. I found out where it was happening after searching high and low for the problem thinking it was my code causing the error. Turns out it had absolutely nothing to do with my code and everything to do with a Telerik control I am using called "RadGridView" which is essentially their version of DataGridView. I like it better than the stock control, but holy crap this was a big mind #&$% just now for no reason.

Here is why the error occurred:
I used the wrong type of format string for a Column that contains a DateTime object. This apparently causes the thread the control is running on to fall to its knees and die. Wow. And it isn't obvious either, this didn't happen when I didn't use the correct format string for other columns, it would just show me the string I provided - harmless.

Don't do this:

If you put the wrong or malformed format string in the FormatString property you will get the following exception during runtime after setting the DataSource property in your code:

This exception is going in the hall of shame because it doesn't tell you anything. USELESS!

Well it turns out the right way to format anything in Telerik controls is by using the following format: {0:FormatString} which is very similar to what you would do when formatting a string in the string.Format() method.

This is one hell of a gotcha, I should probably submit a bug report to Telerik because this truly is a bug.