K
Ken Foskey
I have an object ScriptWords derived from "Dictionary<String,object>" and
I want to sort words.Keys in simple string order but the whole
orderby<> totally eludes me. Can someone help me. Reading msdn or
searching google is not getting me to a sample I can understand.
I could use SortedDictionary however this form use should be extremely
small (more of a debugging tool) and I am happy to for the screen build
to be slightly slower for general application performance.
See the TODO in the code below.
DictionaryView in the code is defined:
private System.Windows.Forms.DataGridView DictionaryView;
public partial class WordDictionary : Form
{
BindingList<WordValue> Words = new BindingList<WordValue>();
/// <summary>
/// Create new screen that is a simple look at the data available
to scripting
/// </summary>
/// <param name="words"></param>
public WordDictionary( ScriptWords words )
{
InitializeComponent();
// TODO: Sort word dictionary into key order
foreach (String key in words.Keys )
{
WordValue temp = new WordValue();
temp.Key = key;
Object t = words[key];
if (t == null)
temp.Value = "Null - Contact support";
else
temp.Value = words[key].ToString();
Words.Add(temp);
}
DictionaryView.DataSource = Words;
DictionaryView.Columns[0].AutoSizeMode =
DataGridViewAutoSizeColumnMode.AllCells;
DictionaryView.Columns[0].SortMode =
DataGridViewColumnSortMode.Automatic;
DictionaryView.Columns[1].AutoSizeMode =
DataGridViewAutoSizeColumnMode.AllCells;
}
}
Ken
I want to sort words.Keys in simple string order but the whole
orderby<> totally eludes me. Can someone help me. Reading msdn or
searching google is not getting me to a sample I can understand.
I could use SortedDictionary however this form use should be extremely
small (more of a debugging tool) and I am happy to for the screen build
to be slightly slower for general application performance.
See the TODO in the code below.
DictionaryView in the code is defined:
private System.Windows.Forms.DataGridView DictionaryView;
public partial class WordDictionary : Form
{
BindingList<WordValue> Words = new BindingList<WordValue>();
/// <summary>
/// Create new screen that is a simple look at the data available
to scripting
/// </summary>
/// <param name="words"></param>
public WordDictionary( ScriptWords words )
{
InitializeComponent();
// TODO: Sort word dictionary into key order
foreach (String key in words.Keys )
{
WordValue temp = new WordValue();
temp.Key = key;
Object t = words[key];
if (t == null)
temp.Value = "Null - Contact support";
else
temp.Value = words[key].ToString();
Words.Add(temp);
}
DictionaryView.DataSource = Words;
DictionaryView.Columns[0].AutoSizeMode =
DataGridViewAutoSizeColumnMode.AllCells;
DictionaryView.Columns[0].SortMode =
DataGridViewColumnSortMode.Automatic;
DictionaryView.Columns[1].AutoSizeMode =
DataGridViewAutoSizeColumnMode.AllCells;
}
}
Ken