Click here to Skip to main content
15,905,028 members
Home / Discussions / C#
   

C#

 
GeneralRe: Applying security for dotnet application Pin
_awatts8-Aug-09 5:26
_awatts8-Aug-09 5:26 
GeneralRe: Applying security for dotnet application Pin
CoderForEver8-Aug-09 8:56
CoderForEver8-Aug-09 8:56 
GeneralRe: Applying security for dotnet application Pin
harold aptroot8-Aug-09 8:59
harold aptroot8-Aug-09 8:59 
AnswerRe: Applying security for dotnet application Pin
Muhammad Mazhar8-Aug-09 3:41
Muhammad Mazhar8-Aug-09 3:41 
QuestionHow To Create multiple workspaces? each of workspace will contain multiple forms? [modified] Pin
shaktisinh8-Aug-09 1:18
shaktisinh8-Aug-09 1:18 
AnswerRe: How To Create multiple workspaces? each of workspace will contain multiple forms? Pin
Luc Pattyn8-Aug-09 1:34
sitebuilderLuc Pattyn8-Aug-09 1:34 
AnswerRe: How To Create multiple workspaces? each of workspace will contain multiple forms? Pin
Muhammad Mazhar8-Aug-09 3:37
Muhammad Mazhar8-Aug-09 3:37 
AnswerRe: How To Create multiple workspaces? each of workspace will contain multiple forms? Pin
Mycroft Holmes8-Aug-09 14:10
professionalMycroft Holmes8-Aug-09 14:10 
QuestionMessage Box changing focus & moved to the back of the parent window [modified] Pin
honeyashu7-Aug-09 22:58
honeyashu7-Aug-09 22:58 
AnswerRe: Message Box changing focus & moved to the back of the parent window Pin
Luc Pattyn8-Aug-09 0:17
sitebuilderLuc Pattyn8-Aug-09 0:17 
GeneralRe: Message Box changing focus & moved to the back of the parent window Pin
honeyashu8-Aug-09 0:45
honeyashu8-Aug-09 0:45 
GeneralRe: Message Box changing focus & moved to the back of the parent window Pin
Luc Pattyn8-Aug-09 1:32
sitebuilderLuc Pattyn8-Aug-09 1:32 
GeneralRe: Message Box changing focus & moved to the back of the parent window Pin
honeyashu10-Aug-09 3:29
honeyashu10-Aug-09 3:29 
QuestionFlash on WebBrowser?? Pin
Muammar©7-Aug-09 22:32
Muammar©7-Aug-09 22:32 
AnswerSolved! Pin
Muammar©7-Aug-09 23:08
Muammar©7-Aug-09 23:08 
QuestionHow do you sort a listBox by number value rather than alphabetically Pin
Nathan Revka7-Aug-09 22:17
Nathan Revka7-Aug-09 22:17 
AnswerRe: How do you sort a listBox by number value rather than alphabetically Pin
Henry Minute8-Aug-09 0:01
Henry Minute8-Aug-09 0:01 
AnswerRe: How do you sort a listBox by number value rather than alphabetically Pin
Moreno Airoldi8-Aug-09 0:03
Moreno Airoldi8-Aug-09 0:03 
You can implement a custom type for Cards and override the CompareTo() method to implement custom sorting. Something like:

C#
        internal enum CardSuits
        {
            Spades = 0,
            Hearts,
            Diamonds,
            Clubs
        }

        internal enum CardValues
        {
            Two = 0,
            Three,
            Four,
            Five,
            Six,
            Seven,
            Eight,
            Nine,
            Ten,
            Jack,
            Queen,
            King,
            Ace
        }

        internal class Card : IComparable
        {
            internal CardSuits Suit;
            internal CardValues Value;

            internal Card(CardSuits Suit, CardValues Value)
            {
                this.Suit = Suit;
                this.Value = Value;
            }

            public int CompareTo(object obj)
            {
                int MyValue = (int)Value;
                Card OtherCard = (Card)obj;
                int OtherValue = (int)OtherCard.Value;
                return MyValue.CompareTo(OtherValue);
            }

            public override string ToString()
            {
                StringBuilder sb = new StringBuilder();
                switch (Value)
                {
                    case CardValues.Two:
                        sb.Append("Two");
                        break;
                    case CardValues.Three:
                        sb.Append("Three");
                        break;
                    case CardValues.Four:
                        sb.Append("Four");
                        break;
                    case CardValues.Five:
                        sb.Append("Five");
                        break;
                    case CardValues.Six:
                        sb.Append("Six");
                        break;
                    case CardValues.Seven:
                        sb.Append("Seven");
                        break;
                    case CardValues.Eight:
                        sb.Append("Eight");
                        break;
                    case CardValues.Nine:
                        sb.Append("Nine");
                        break;
                    case CardValues.Ten:
                        sb.Append("Ten");
                        break;
                    case CardValues.Jack:
                        sb.Append("Jack");
                        break;
                    case CardValues.Queen:
                        sb.Append("Queen");
                        break;
                    case CardValues.King:
                        sb.Append("King");
                        break;
                    case CardValues.Ace:
                        sb.Append("Ace");
                        break;
                    default:
                        sb.Append("???");
                        break;
                }
                sb.Append(" of ");
                switch (Suit)
                {
                    case CardSuits.Spades:
                        sb.Append("Spades");
                        break;
                    case CardSuits.Hearts:
                        sb.Append("Hearts");
                        break;
                    case CardSuits.Diamonds:
                        sb.Append("Diamonds");
                        break;
                    case CardSuits.Clubs:
                        sb.Append("Clubs");
                        break;
                    default:
                        sb.Append("???");
                        break;
                }
                return sb.ToString();
            }
        }

...

            List<Card>CardList = new List<Card>();
            CardList.Add(new Card(CardSuits.Hearts, CardValues.Three));
            CardList.Add(new Card(CardSuits.Clubs, CardValues.Queen));
            CardList.Add(new Card(CardSuits.Diamonds, CardValues.Nine));
            CardList.Add(new Card(CardSuits.Spades, CardValues.Ace));

            CardList.Sort();

            listBox1.DataSource = CardList;


2+2=5 for very large amounts of 2
(always loved that one hehe!)

AnswerRe: How do you sort a listBox by number value rather than alphabetically [modified] Pin
Luc Pattyn8-Aug-09 0:13
sitebuilderLuc Pattyn8-Aug-09 0:13 
QuestionHow do you sort a listBox by number value rather than alphabetically Pin
Nathan Revka7-Aug-09 22:17
Nathan Revka7-Aug-09 22:17 
QuestionSplit text and Store into Arry List Pin
M Riaz Bashir7-Aug-09 20:28
M Riaz Bashir7-Aug-09 20:28 
AnswerRe: Split text and Store into Arry List Pin
Abhijit Jana7-Aug-09 21:42
professionalAbhijit Jana7-Aug-09 21:42 
GeneralRe: Split text and Store into Arry List Pin
OriginalGriff7-Aug-09 22:04
mveOriginalGriff7-Aug-09 22:04 
GeneralRe: Split text and Store into Arry List Pin
Abhijit Jana7-Aug-09 22:17
professionalAbhijit Jana7-Aug-09 22:17 
AnswerRe: Split text and Store into Arry List Pin
Arindam Sinha7-Aug-09 21:58
Arindam Sinha7-Aug-09 21:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.