Feb2010
18

WinForms Controls – Displaying a vertical tab

by nmgomes

It’s been several years since my last WinForms programming experience - I’m a ASP.NET maniac since 2002/2003 – but this year started with an unexpected challenge: build a Visual Studio  2008 Integration Package (VSIP) with an advanced Editor for some in-house metadata xml structure.

If you already did some work related to VSIP is no surprise that I was forced to embrace the long ago forgotten Winforms controls specificities.

Maybe I simply forgot or never noticed before, but the TabControl when operating in vertical mode – either Left or Right – display an amazing poor user experience and in most cases text are not showed.

Ok, no big deal, TabControl have enough extensibility points to enable us to work around and its even available a Msdn article with the recipe: How to: Display Side-Aligned Tabs with TabControl.

Maybe it’s just me but this is the kind of behavior I did expect to be fully available and functional since it seams to be quite common in most applications.

Filed in: WinForms

Feb2010
14

Tools – RedGate just release the new .NET Reflector 6.0 and .NET Reflector Pro

by nmgomes

The long waiting, for RedGate to release the new official .NET Reflector version, is finally ended.

I must say that as far as I know (and I was an early adopter and usability tester), RedGate took special care with this new version, specially the new Reflector Pro version.

This new product (€145)  integrates the technology of .NET Reflector into Visual Studio to let you debug third-party code even if you don't have the source.

You can say that this can also be done without this product, and it’s absolutely true, but the simplicity how the integration with Visual Studio (2005, 2008 or 2010) is done worth it .

I use this tool since the beta versions and I’m addicted ;) … try it for yourself.

Filed in:

Oct2009
9

ASP.NET Controls – Problem sorting GridView with SqlDataSource control

by nmgomes

Let me start by saying that Microsoft don't consider this issue as a problem, as you can see here this is a “by design” behavior.

The problem is well described in the referred Connect feedback and it contains a workaround.

Although simple, the workaround requires you to always register the GridView Sorting event and make the tweak according to the current GridView settings. Well, if are like me you will forget to do it half the times needed.

So, I made a not so simple workaround that will take care of the issue for me.

I override the OnSorting method from GridView so I can handle the GridViewEventArgs instance and override its SortDirection value.

To turn this into a general solution I partially reproduce the ParseSortString method from DataTable to find out if the current SortExpression contains either the ASC or DESC keywords.

Here is the code:

public class GridView : global::System.Web.UI.WebControls.GridView{    protected override void OnSorting(GridViewSortEventArgs e)    {        if (!string.IsNullOrEmpty(this.SortExpression))        {            if (this.SortExpression.Equals(this.SortExpression))            {                bool isMultipleSortExpression;                SortDirection? sortDirection = GetSortDirection(this.SortExpression, out isMultipleSortExpression);                if (sortDirection.HasValue)                {                    // To undo bug in GridView.HandleSort(string sortExpression) and then in GridView.CreateDataSourceSelectArguments()                    e.SortDirection = SortDirection.Ascending;                }            }        }        base.OnSorting(e);    }    private SortDirection? GetSortDirection(string sortExpression, out bool isMultipleSortExpression)    {        SortDirection? sortDirection = null;        isMultipleSortExpression = false;        string[] strArray = sortExpression.Split(new char[] { ',' });        for (int i = 0; i < strArray.Length; i++)        {            string strA = strArray[i].Trim();            int length = strA.Length;            if ((length >= 5) && (string.Compare(strA, length - 4, " ASC", 0, 4, StringComparison.OrdinalIgnoreCase) == 0))            {                sortDirection = SortDirection.Ascending;            }            else if ((length >= 6) && (string.Compare(strA, length - 5, " DESC", 0, 5, StringComparison.OrdinalIgnoreCase) == 0))            {                sortDirection = SortDirection.Descending;            }            if (!sortDirection.HasValue)            {                break;            }        }        if (sortDirection.HasValue)        {            if (strArray.Length > 1)            {                isMultipleSortExpression = true;            }        }        return sortDirection;    }}

Enjoy it.

Filed in: ASP.NET | CodeProject