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

下載本文檔

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

文檔簡(jiǎn)介

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

2、,廣州易麥科技 ,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,廣州易麥科技 ,日 期: System.Windows.Fo

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

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

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

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

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

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

9、.Properties.ShowHeader=false;/不顯示頁(yè)眉(包括列頭) this.lookUpEdit1.Properties.ShowFooter = false;/不顯示頁(yè)腳(包括關(guān)閉按鈕) this.lookUpEdit1.Properties.DisplayMember = Name;/要顯示的字段,Text獲得 this.lookUpEdit1.Properties.ValueMember = Value;/實(shí)際值的字段,EditValue獲得 /數(shù)據(jù)綁定 ICollection list = Global.ClassCategoryList; this.lookUpEd

10、it1.Properties.DataSource = list;/綁定數(shù)據(jù) this.lookUpEdit1.Properties.DropDownRows =list.Count;/設(shè)置行數(shù)(根據(jù)這個(gè)自動(dòng)設(shè)置高度),廣州易麥科技 ,2:GridControl GridControl可以代替.net的System.Windows.Forms.DataGrid控件。 GirdControl只是一個(gè)容器控件,必須要求GridView視圖作為它的子控件。 GridControl可以包含多個(gè)視圖,可以實(shí)現(xiàn)視圖的切換。 每個(gè)視圖必須包含列(Column) GridControl支持層級(jí)視圖,廣州易麥科

11、技 ,GridControl常設(shè)置屬性 使用導(dǎo)航器 this.gridControl1.UseEmbeddedNavigator = true; this.gridControl1.EmbeddedNavigator.Buttons.Append.Visible = false; this.gridControl1.EmbeddedNavigator.Buttons.CancelEdit.Visible = false; this.gridControl1.EmbeddedNavigator.Buttons.Edit.Visible = false; this.gridControl1.Emb

12、eddedNavigator.Buttons.EndEdit.Visible = false; this.gridControl1.EmbeddedNavigator.Buttons.Remove.Visible = false; this.gridControl1.EmbeddedNavigator.Buttons.First.Visible = true; this.gridControl1.EmbeddedNavigator.Buttons.Last.Visible = true; this.gridControl1.EmbeddedNavigator.Buttons.Next.Visi

13、ble = true; this.gridControl1.EmbeddedNavigator.Buttons.NextPage.Visible = true; this.gridControl1.EmbeddedNavigator.Buttons.Prev.Visible = true; this.gridControl1.EmbeddedNavigator.Buttons.PrevPage.Visible = true;,廣州易麥科技 ,GridView常設(shè)置屬性 this.gridView1.OptionsBehavior.Editable = false;/禁止編輯 this.grid

14、View1.OptionsCustomization.AllowFilter = false;/不允許使用過(guò)濾 this.gridView1.OptionsCustomization.AllowSort = false;/不允許使用排序 this.gridView1.OptionsView.ShowGroupPanel = false;/不顯示組面板 this.gridView1.OptionsView.ColumnAutoWidth =true;/如果寬度溢出,自動(dòng)出現(xiàn)滾動(dòng)條 this.gridView1.OptionsSelection.EnableAppearanceFocusedCel

15、l = false;/禁止單元格獲得焦點(diǎn) this.gridView1.Appearance.SelectedRow.BackColor = Color.Transparent;/選擇的行背景透明,廣州易麥科技 ,事件 /訂閱行焦點(diǎn)改變事件 this.gridView1.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged); /驗(yàn)證編輯器(單元格)值輸入 this.gridView1.ValidatingEdi

16、tor += new DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventHandler(this.gridView1_ValidatingEditor); private void gridView1_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e) if (gridView1.FocusedColumn = col產(chǎn)品名稱) if (string.IsNull

17、OrEmpty(e.Value as string) e.ErrorText = 產(chǎn)品名稱不能為空; e.Valid = false; ,廣州易麥科技 ,/訂閱設(shè)置行風(fēng)格事件 this.gridView1.RowStyle += new DevExpress.XtraGrid.Views.Grid.RowStyleEventHandler(this.gridView1_RowStyle); private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e) obje

18、ct value = gridView1.GetRowCellValue(e.RowHandle, 中止); if (value!=null ,廣州易麥科技 ,this.gridView1.CustomColumnDisplayText += new DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventHandler(this.gridView1_CustomColumnDisplayText); private DataTable _CategoryList; public DataTable CategoryList get

19、 if (_CategoryList = null) _CategoryList=GetData(select * from 產(chǎn)品類別); DataColumn 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.Find(e.Value)類別名稱 as string; ,廣州易麥科技 ,/行單元格對(duì)齊 this.gridV

溫馨提示

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

評(píng)論

0/150

提交評(píng)論