第一次做winform介面問題總結

來源:互聯網
上載者:User

標籤: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

繼續研究,不太明白!

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.