DevExpress入門教程_第1頁
DevExpress入門教程_第2頁
DevExpress入門教程_第3頁
DevExpress入門教程_第4頁
DevExpress入門教程_第5頁
已閱讀5頁,還剩16頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、DeVExpress控件入門簡介簡介: XtraEditors Library是專門為可視化的Studio.NET設(shè)計的最優(yōu)化的一套100的C#控件 XtraEdiotors Library是一款具有革命性的超過20種數(shù)據(jù)編輯控制的控件它是國內(nèi)第一個適合于.NET框架類型的控件。廣州易麥科技 http:/準(zhǔn)備工作1.DevExpress控件的安裝2.Demo查看3.幫助文檔使用廣州易麥科技 http:/一:與.net基本的控件比較1:命名空間(NameSpace).net基本控件的類都在System.Windows.Forms的命名控件下DevExpress的控件類在DevExpress命名空

2、間下廣州易麥科技 http:/2:可以代替.net的控件DevExpress的大部分控件都已可以代碼.net的基本控件。如:文本框:System.Windows.Forms.TextBox - DevExpress.XtraEditors.TextEdit按鈕:System.Windows.Forms.Button - DevExpress.XtraEditors.SimpleButton下拉框:System.Windows.Forms.ComboBox - DevExpress.XtraEditors.ComboBoxEdit廣州易麥科技 http:/日 期:System.Windows.F

3、orms.DateTimePicker - DevExpress.XtraEditors.DateEdit/DevExpress.XtraEditors.TimeEdit復(fù)選框System.Windows.Forms.CheckBox - DevExpress.XtraEditors.CheckEdit這里就不一一列舉了,認(rèn)真看看,相信一定找出很多可以替代的控件廣州易麥科技 http:/二:幾個比較重要、常用的屬性1:EditValue DevExpress.XtraEditors.*Edit的控件都不可少的一個EditValue屬性。如:DevExpress.XtraEditors.*Edi

4、t 通常,EditValue會跟Text的值是一樣的。只是EditValue的類型為Object,Text的屬性為String,也就是EditValue通??梢源鎀ext屬性。2:Enable和Visable 是否禁用和是否可見廣州易麥科技 http:/3:Properties設(shè)置控件一些特征DevExpress.XtraEditors.TextEdit txt=.;例:是否只讀txt.Properties.ReadOnly=true;不允許獲得焦點(diǎn)txt.Properties.AllowFocused = false;不允許空值輸入txt.Properties.AllowNullInput

5、=true;/當(dāng)這個屬性應(yīng)用在TimeEdit中,它的清除按鈕,將會禁用(灰掉)廣州易麥科技 http:/禁止編輯器輸入如: ComboBoxEdit c=.; c.Properties.TextEditStyle=DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;/只選模式,不能輸入文本廣州易麥科技 http:/4:Appearance設(shè)置風(fēng)格。Dexpress把所有設(shè)置控件風(fēng)格的特性都放到Appearance屬性下。例:DevExpress.XtraEditors.SimpleButton btn=.;btn.

6、Appearance.ForeColor = Color.Red;/前景色btn.Appearance.BackColor = Color.Red;/背景色廣州易麥科技 http:/ Appearance.TextOptions文本對齊操作例:btn.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;/居中對齊btn.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;/自動換行。當(dāng)控件的寬度容不下文本的長度,會自動換行

7、。注意,在某些控件中Apperarance是在Properties屬性下的如:DevExpress.XtraEditors.TextEdit txt=.;txt.Properties.Appearance.ForeColor = Color.Red;廣州易麥科技 http:/三:幾個常用的控件1:用強(qiáng)大的LookUpEdit代替ComboBox 1.1 ComboBox不支持?jǐn)?shù)據(jù)綁定2.1 由于DevExpress的ComboBox天生的數(shù)據(jù)綁定缺陷,所以有時我們要做數(shù)據(jù)綁定,不得不使用下“功能過?!钡腖ooUpEdit。如下代碼,可用實(shí)現(xiàn)一個ComboBox:廣州易麥科技 http:/ /禁

8、止文本輸入禁止文本輸入 this.lookUpEdit1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; /默認(rèn)為默認(rèn)為null的顯示的顯示 this.lookUpEdit1.Properties.NullText = 請選擇類別請選擇類別; /加入一個顯示列加入一個顯示列 this.lookUpEdit1.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo(

9、Name); this.lookUpEdit1.Properties.ShowHeader=false;/不顯示頁眉(包括列頭)不顯示頁眉(包括列頭) this.lookUpEdit1.Properties.ShowFooter = false;/不顯示頁腳(包括關(guān)閉按鈕)不顯示頁腳(包括關(guān)閉按鈕) this.lookUpEdit1.Properties.DisplayMember = Name;/要顯示的字段要顯示的字段,Text獲得獲得 this.lookUpEdit1.Properties.ValueMember = Value;/實(shí)際值的字段實(shí)際值的字段,EditValue獲獲得得 /

10、數(shù)據(jù)綁定數(shù)據(jù)綁定 ICollection list = Global.ClassCategoryList; this.lookUpEdit1.Properties.DataSource = list;/綁定數(shù)據(jù)綁定數(shù)據(jù) this.lookUpEdit1.Properties.DropDownRows =list.Count;/設(shè)置行數(shù)設(shè)置行數(shù)(根據(jù)這個自根據(jù)這個自動設(shè)置高度動設(shè)置高度)廣州易麥科技 http:/ 2:GridControlGridControl可以代替.net的System.Windows.Forms.DataGrid控件。GirdControl只是一個容器控件,必須要求Gri

11、dView視圖作為它的子控件。GridControl可以包含多個視圖,可以實(shí)現(xiàn)視圖的切換。每個視圖必須包含列(Column)GridControl支持層級視圖廣州易麥科技 http:/GridControl常設(shè)置屬性常設(shè)置屬性 使用導(dǎo)航器使用導(dǎo)航器 this.gridControl1.UseEmbeddedNavigator = true; this.gridControl1.EmbeddedNavigator.Buttons.Append.Visible = false; this.gridControl1.EmbeddedNavigator.Buttons.CancelEdit.Visib

12、le = false; this.gridControl1.EmbeddedNavigator.Buttons.Edit.Visible = false; this.gridControl1.EmbeddedNavigator.Buttons.EndEdit.Visible = false; this.gridControl1.EmbeddedNavigator.Buttons.Remove.Visible = false; this.gridControl1.EmbeddedNavigator.Buttons.First.Visible = true; this.gridControl1.E

13、mbeddedNavigator.Buttons.Last.Visible = true; this.gridControl1.EmbeddedNavigator.Buttons.Next.Visible = true; this.gridControl1.EmbeddedNavigator.Buttons.NextPage.Visible = true; this.gridControl1.EmbeddedNavigator.Buttons.Prev.Visible = true; this.gridControl1.EmbeddedNavigator.Buttons.PrevPage.Vi

14、sible = true;廣州易麥科技 http:/GridView常設(shè)置屬性常設(shè)置屬性 this.gridView1.OptionsBehavior.Editable = false;/禁止編輯禁止編輯 this.gridView1.OptionsCustomization.AllowFilter = false;/不允許使用不允許使用過濾過濾 this.gridView1.OptionsCustomization.AllowSort = false;/不允許使用排不允許使用排序序 this.gridView1.OptionsView.ShowGroupPanel = false;/不顯示組

15、面板不顯示組面板 this.gridView1.OptionsView.ColumnAutoWidth =true;/如果寬度溢出,如果寬度溢出,自動出現(xiàn)滾動條自動出現(xiàn)滾動條 this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;/禁止單元格獲得焦點(diǎn)禁止單元格獲得焦點(diǎn) this.gridView1.Appearance.SelectedRow.BackColor = Color.Transparent;/選擇的行背景透明選擇的行背景透明廣州易麥科技 http:/ 事件事件/訂閱行焦點(diǎn)改變事件訂閱行焦點(diǎn)改變事件th

16、is.gridView1.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged);/驗(yàn)證編輯器(單元格)值輸入驗(yàn)證編輯器(單元格)值輸入this.gridView1.ValidatingEditor += new DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventHandler(this.gridView1_ValidatingEdit

17、or);private void gridView1_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e) if (gridView1.FocusedColumn = col產(chǎn)品名稱產(chǎn)品名稱) if (string.IsNullOrEmpty(e.Value as string) e.ErrorText = 產(chǎn)品名稱不能為空產(chǎn)品名稱不能為空; e.Valid = false; 廣州易麥科技 http:/ += new DevExpress.X

18、traGrid.Views.Grid.RowStyleEventHandler(this.gridView1_RowStyle);private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e) object value = gridView1.GetRowCellValue(e.RowHandle, 中止中止); if (value!=null&(bool)value) e.Appearance.ForeColor = Color.Red; 廣州易麥科技

19、 http:/this.gridView1.CustomColumnDisplayText += new DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventHandler(this.gridView1_CustomColumnDisplayText);private DataTable _CategoryList;public DataTable CategoryList get if (_CategoryList = null) _CategoryList=GetData(select * from 產(chǎn)品類別產(chǎn)品類別); D

20、ataColumn pk = _CategoryList.Columns類別類別ID; _CategoryList.PrimaryKey = new DataColumn pk;return _CategoryList; private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) if (e.Column.Name = col類別類別ID) e.DisplayText = CategoryList.Rows.

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論