一些被废弃的代码:
1、dataGrid1_MouseDown:
private void dataGrid1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
//HitTest 方法返回包含所单击区域的行和列的 DataGrid.HitTestInfo 对象
DataGrid myGrid = (DataGrid) sender;
System.Windows.Forms.DataGrid.HitTestInfo hti;
hti = myGrid.HitTest(e.X, e.Y);
switch (hti.Type)
{
case System.Windows.Forms.DataGrid.HitTestType.ColumnHeader : //列 头
//SortColumn(dataGrid1,hti.Column);
//SortDataGrid(sender, e);
break;
}
}
2、运行时间
DateTime startTime = System.DateTime.Now;
TimeSpan ts= DateTime.Now.Subtract(startTime);
double count= ts.TotalMilliseconds;
MessageBox.Show("页面执行所用时间1:"+count.ToString());
System.DateTime endTime = System.DateTime.Now;
System.TimeSpan ts2= endTime - startTime;
MessageBox.Show("页面执行所用时间2:" + ts2.Milliseconds + " 毫秒");
3、构造一些combox的DataSource :
#region/***教育程度***/
private void FillComboBoxSorts()
{
try
{
this.cmbSort.Items.Clear();
this.cmbSort.Items.Add("小学");
this.cmbSort.Items.Add("初中");
this.cmbSort.Items.Add("高中");
}
catch (Exception err)
{
MessageBox.Show(this,err.Message,"加载学科",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void cmbSort_SelectedIndexChanged(object sender, System.EventArgs e)
{
string selectedText=cmbSort.Text;
p_operTableName=string.Empty;
cmbGetTableName.SelectedIndex=-1;
if(selectedText.IndexOf("小学")>-1)
{
p_operTableName="小学";
}
else if(selectedText.IndexOf("初中")>-1)
{
p_operTableName="初中";
}
else if(selectedText.IndexOf("高中")>-1)
{
p_operTableName="高中";
}
this.cmbGetTableName.Enabled=true;
FillComboxTableNames();
}
#endregion
#region/***构造课程***/
private void SetHashTable()
{
hashT=new Hashtable();
hashT.Add( "数学","SHUXUE");
hashT.Add( "语文", "YUWEN" );
hashT.Add( "英语", "YINGYU" );
hashT.Add( "地理", "DILI" );
hashS=new Hashtable();
hashS.Add( "英语", "YINGYU" );
hashS.Add( "语文", "YUWEN" );
hashS.Add( "数学","SHUXUE");
}
#endregion
#region /***操作课程***/
private void FillComboxTableNames()
{
try
{
cmbGetTableName.Items.Clear();
if(p_operTableName.IndexOf("小学")>-1)
{
if(hashS!=null)
{
IDictionaryEnumerator myEnumerator=hashS.GetEnumerator();
while ( myEnumerator.MoveNext() )
cmbGetTableName.Items.Add(myEnumerator.Key );
}
}
else if(p_operTableName.IndexOf("初中")>-1)
{
if(hashT!=null)
{
IDictionaryEnumerator myEnumerator=hashT.GetEnumerator();
while ( myEnumerator.MoveNext() )
cmbGetTableName.Items.Add(myEnumerator.Key );
}
}
else if(p_operTableName.IndexOf("高中")>-1)
{
if(hashT!=null)
{
IDictionaryEnumerator myEnumerator=hashT.GetEnumerator();
while ( myEnumerator.MoveNext() )
cmbGetTableName.Items.Add(myEnumerator.Key );
}
}
//this.cmbOperTableName.SelectedIndex=0;
}
catch (Exception err)
{
MessageBox.Show(this,err.Message,"加载科目",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void cmbGetTableName_SelectedIndexChanged(object sender, System.EventArgs e)
{
string myValue=string.Empty;
string selectedText=cmbGetTableName.Text;
if(hashT.ContainsKey(selectedText))
{
myValue=selectedText.ToString();
p_operTableName+=myValue;
}
else if(hashS.ContainsKey(selectedText))
{
myValue=selectedText.ToString();
p_operTableName+=myValue;
}
}
#endregion