?
Solved

Custom Sorting of String

Posted on 2013-11-04
5
Medium Priority
?
709 Views
Last Modified: 2013-11-07
I'm new to Visual Studio and C# but i am using Devexpress 13.1 to create my Pivotgrid. My column header currently display items by alphabetical Sizes. Example: Current column header displays '3X-Large','Large','Medium','Small','X-Large',X-Small','XX-Large'.

I'm looking to display my column header by 'X-Small','Small','Medium','Large','X-Large','XX-Large','3X-Large'. I found some stuff on doing array sorts but i'm having trouble doing this string sort. I'm currently using C# in my project. Any suggestions?
0
Comment
Question by:Southern_Gentleman
  • 2
  • 2
4 Comments
 
LVL 46

Expert Comment

by:aikimark
ID: 39624113
@Southern_Gentleman

Is there another column that reflects the actual size of the items as a numeric value?  You might leave that column hidden (zero width) for the UI and only use it for sorting or filtering purposes.
0
 

Author Comment

by:Southern_Gentleman
ID: 39625615
Thanks Aikimark, I tried your method with the numeric value and tried to hide it but it won't allow me to set the column width to zero. When I hide the column of numeric values, the columns reset to automatically sort it alphabetically by the text string of sizes. I liked your idea but it kind of looks like we may need to do it by c# code.
0
 
LVL 46

Accepted Solution

by:
aikimark earned 2000 total points
ID: 39625624
according to this Devexpress, this is how to 'hide' a column in their pivotgrid:

using System;
using System.Windows.Forms;
using DevExpress.XtraPivotGrid;

namespace XtraPivotGrid_ExampleTemplate {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {
            nwindDataSetTableAdapters.ProductReportsTableAdapter adapter =
                new nwindDataSetTableAdapters.ProductReportsTableAdapter();
            pivotGridControl1.DataSource = adapter.GetData();
            pivotGridControl1.BestFit();
        }
        private void pivotGridControl1_CustomFieldValueCells(object sender, 
            PivotCustomFieldValueCellsEventArgs e) {
            if (pivotGridControl1.Fields.GetVisibleFieldCount(PivotArea.ColumnArea) == 0
                && ceHideColumnGrandTotal.Checked)
                e.Remove(e.GetCell(true, 0));
        }
        private void ceHideColumnGrandTotal_CheckedChanged(object sender, EventArgs e) {
            pivotGridControl1.RefreshData();
        }
    }
}

Open in new window

code example source:
http://www.devexpress.com/Support/Center/Example/Details/E2683
0
 

Author Closing Comment

by:Southern_Gentleman
ID: 39631234
Thanks again.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Loops Section Overview

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question