Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Mario Orlandi

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Fill combobox with enum values

public enum CardDataType
{
    Unknown,
    Raw,
    RowChp
}

ctlDataType.DataSource = Enum.GetValues(typeof(CardDataType));
ctlDataType.SelectedItem = CardDataType.Unknown;

...
...
string strType = ctlDataType.SelectedItem.ToString();

or

CardDataType dataType;
string strDataType = "Raw";
dataType = (CardDataType)Enum.Parse(typeof(CardDataType), strDataType, true);

and eventually

ctlDataType.SelectedItem = dataType; 

// a volte da' problemi in fase di inizializzazione della UI;
// in questi casi si puo' ricorrere a Enum.GetNames()
foreach ( string name in Enum.GetNames(typeof(CardDataType)) ) 
{
    ctlDataType.Items.Add(name);
}

...

string strDataType = "Raw";
ctlDataType.SelectedItem = strDataType; 

ArrayList

using System.Collections;

ArrayList arrList = new ArrayList();

arrList.Add("one");
arrList.Add("two");
arrList.Add("three");

string[] strArray = arrList.ToArray(Type.GetType("System.String")) as string[];
return strArray;
       

autoscroll text

    textBox1.SelectionStart = textBox1.Text.Length;
    textBox1.SelectionLength = 0;
    textBox1.ScrollToCaret();    
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS