Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. i cant believe its not butter...or that i wrote this

i cant believe its not butter...or that i wrote this

Scheduled Pinned Locked Moved The Weird and The Wonderful
algorithmsdebuggingquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SomeGuyThatIsMe
    wrote on last edited by
    #1

    the point was to do 2 column reversable order sorting, i wrote this thing as an intern.. have fun guys and gals.

            int    t1   = 0;
            int    t2   = 0;
            string temp = "";
            string orig = "";
    
            if (lblSortOrder.Text==e.SortExpression)//if they click the same column reverse order
            {
                Trace.Write("asdf","in order switcher");
                lblSortOrder.Text +=" DESC";
            }
            else if (lblSortOrder.Text.IndexOf(e.SortExpression)== -1)//if they click a different column use both sort terms
            {
                Trace.Write("asdf","in column adder");
                temp=e.SortExpression;
                temp+=", "+lblSortOrder.Text;
                lblSortOrder.Text=temp;
            }
            else if (lblSortOrder.Text.IndexOf(',')!=-1)//if the first two fail and is a multi column search
            {    
                if (lblSortOrder.Text.IndexOf(e.SortExpression)!=-1)//if expression is in the sort string, make it primary and reverse its order
                {
                    orig=lblSortOrder.Text;
                    t1=orig.IndexOf(e.SortExpression);
                    t2=orig.IndexOf(",",t1)-t1;
    
                    if(t2>=0)
                    {
                        temp=orig.Substring(t1,t2);
                    }
                    else
                    {
                        temp=orig.Substring(t1);
                    }
                    //Trace.Write("orig after substring",orig);
                    //Trace.Write("temp",temp);
                    
                    if(temp.IndexOf("DESC")!=-1)
                    {
                        orig=orig.Remove(t1,temp.Length);
                        temp=temp.Remove(temp.IndexOf("DESC"),4);
                        temp=temp.Trim();
                        //Trace.Write("remove desc",temp);
                    }
                    else
                    {
                        orig=orig.Remove(t1,temp.Length);
                        temp+=" DESC";
                        temp=temp.Trim();
                        //Trace.Write("add desc",temp);
                    }
                    orig=orig.Trim();
                    lblSortOrder.Text=temp+","+orig;
                }//end if sort expression contained in sort string
                else
                {
                    lblSortOrder.Text=e.SortExpression;
                    //Trace.Write("???","you sho
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups