첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ XAML

<Grid xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid">
    <dxg:GridControl x:Name="gridControl"
        CustomColumnSort="gridControl_CustomColumnSort">
        <dxg:GridControl.Columns>
        <dxg:GridColumn FieldName="CustomerID"  />
        <dxg:GridColumn FieldName="ShippedDate" />
        <dxg:GridColumn
            FieldName="ShipName"
            SortMode="Custom" />
        <dxg:GridColumn FieldName="ShipCountry" />
        </dxg:GridControl.Columns>
        <dxg:GridControl.View>
            <dxg:TableView Name="tableView" />
        </dxg:GridControl.View>
    </dxg:GridControl>
</Grid>

 

728x90

 

▶ C#

using System.Collections;

using DevExpress.Xpf.Grid;

#region 그리드 컨트롤 커스텀 컬럼 정렬 처리하기 - gridControl_CustomColumnSort(sender, e)

/// <summary>
/// 그리드 컨트롤 커스텀 컬럼 정렬 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void gridControl_CustomColumnSort(object sender, CustomColumnSortEventArgs e)
{
    if(e.Column.FieldName == "ShipName")
    {
        e.Handled = true;

        string shipName1 = e.Value1.ToString();
        string shipName2 = e.Value2.ToString();

        if(shipName1.Length > shipName2.Length)
        {
            e.Result = 1;
        }
        else 
        {
            if(shipName1.Length == shipName2.Length)
            {
                e.Result = Comparer.Default.Compare(shipName1, shipName2);
            }
            else 
            {
                e.Result = -1;
            }
        }
    }
}

#endregion

 

728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요