コメント
コメントの投稿
※名前とタイトルが入力されていないコメントでは他のコメントとの区別ができません。
入力されていないコメントには返信しませんのであらかじめご了承くださいませ。
ObservableCollection<string> collection { get; set; }
async void OnButtonClick(object sender, EventArgs e)
{
string[] array = ・・・; //Listの元となる文字列配列を取得
foreach (string s in array)
{
//他の処理・・・
//ObservableCollectionに追加する
collection.Add(s);
}
//ソートする
collection = new ObservableCollection<string>(collection.OrderBy(n => n));
//リストビューにバインド
this.ListView1.ItemsSource = collection;
}
ObservableCollection<string> collection { get; set; }
async void OnButtonClick(object sender, EventArgs e)
{
string[] array = ・・・; //Listの元となる文字列配列を取得
this.Sort(ref array); //ここでソートしています。
foreach (string s in array)
{
//他の処理・・・
//ObservableCollectionに追加する
collection.Add(s);
}
//リストビューにバインド
this.ListView1.ItemsSource = collection;
}
void Sort(ref string[] array)
{
//大文字小文字を区別しない序数比較で並び替える
StringComparer cmp = StringComparer.OrdinalIgnoreCase;
Array.Sort(array, cmp);
}
※名前とタイトルが入力されていないコメントでは他のコメントとの区別ができません。
入力されていないコメントには返信しませんのであらかじめご了承くださいませ。