標籤:winform datagridview style code ext color
1.winform表單
a. 最大,最小按鈕:this.maxizebox,this.minizebox
b.不允許使用者修改視窗大小: this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
c.修改標題: this.text
d.視窗置中: this.SetBounds((Screen.GetBounds(this).Width / 2) - (this.Width / 2), (Screen.GetBounds(this).Height / 2) - (this.Height / 2), this.Width, this.Height, BoundsSpecified.Location);
e.滑鼠控制:this.Cursor = Cursors.WaitCursor/default
2.combobox
a.列表不允許使用者輸入,只能從列表選擇:combobox.dropdowstype = dropdownlist
b.combobox選擇項:combobox.selectedIndex & combobox.selectedItem
c.combobox添加項:combobox.Items.Insert(pos,value), combobox.Items.Add(value)
3.datagridview
a.list賦值給datagridview時,要list裡的值屬性和column的屬性必須是一樣的,可以list轉成datatable,讓後賦值給datasource
private DataTable ConvertListToDataTable(List<myInfoData> list)
{
// New table.
DataTable table = new DataTable();
table.Columns.Add("FName");//屬性要一樣
table.Columns.Add("LName");
table.Columns.Add("UName");
table.Columns.Add("Location");
table.Columns.Add("PitName");
table.Columns.Add("GameType");
// Add rows.
foreach (var array in list)
{
table.Rows.Add(array.FirstName, array.LastName, array.UserName, array.Location, array.PitName, array.GameType);
}
return table;
}
b.如果添加datagridview的selectionchanged event,會影響datagridview的排序功能,可以用datagridview的cellclick 或者cellcontentclick事件代替,傳入參數中包含cell的rowindex
c. 清空表格內容:datagridview.datasource.clear()
d.datagridview 總是多出一行:allowuseraddnewrow = false
4.vb和C#程式相互調用
記得要用屬性值傳參數,程式雷根據傳入屬性值調用相應C#orVB code
5.lambda運算式和lingq
list繼承了IEnumrable介面,可以直接將list賦值給IEnumrable,然後用lingq查詢
where,firstordefault,distinct,等等
6.delegate
繼續研究,不太明白!