private
void BindYourDataGridView()
{
// here put data into the HashTable, but you can already have data
// in you hashtable, in this case delete this lines -----------
// here put data into the HashTable, but you can already have data
// in you hashtable, in this case delete this lines -----------
Hashtable
YourData= new Hashtable();
for
(int i = 0; i < something; i++)
YouData.Add(i, something[i]);
//---------------------------------------------------------------------
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add("data");
dt.Columns.Add("A", typeof(string));
dt.Columns.Add("B", typeof(int));
dt.Columns.Add("B", typeof(int));
IDictionaryEnumerator
enumerator = YourData.GetEnumerator();
DataRow
row = null;
//adding row in the datatable
while
(enumerator.MoveNext())
{
int index = (int)enumerator.Key;
string
value = (string)enumerator.Value;
row = dt.NewRow();
row["A"]
= index;
row["B"] = value;
dt.Rows.Add(row);
}
Your_DataGridView.DataSource = ds.Tables[0];
}
My Two Cents ...
My Two Cents ...
Nessun commento:
Posta un commento