资源描述:
《DEV-GridControl小结》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1、如何解决单击记录整行选中的问题View->OptionsBehavior->EditorShowMode设置为:Click 2、如何新增一条记录(1)、gridView.AddNewRow()(2)、实现gridView_InitNewRow事件 3、如何解决GridControl记录能获取而没有显示出来的问题gridView.populateColumns(); 4、如何让行只能选择而不能编辑(或编辑某一单元格)(1)、View->OptionsBehavior->EditorShowMode设置为:Click(2)、View->OptionsBehavior->Ed
2、itable设置为:false 5、如何禁用GridControl中单击列弹出右键菜单设置RunDesign->OptionsMenu->EnableColumnMenu设置为:false 6、如何隐藏GridControl的GroupPanel表头设置RunDesign->OptionsView->ShowGroupPanel设置为:false 7、如何禁用GridControl中列头的过滤器过滤器如下图所示: 设置RunDesign->OptionsCustomization->AllowFilter设置为:false 8、如何在查询得到0条记录时显示自定义的字
3、符提示/显示如图所示:方法如下://WhennoRecordsAreBeingDisplayed privatevoidgridView1_CustomDrawEmptyForeground(objectsender,CustomDrawEventArgse) { //方法一(此方法为GridView设置了数据源绑定时,可用) ColumnViewcolumnView=senderasColumnView; BindingSourcebindingSource=this.gridView1.DataSourceasBindingSource; if(bindingSourc
4、e.Count==0) { stringstr="没有查询到你所想要的数据!"; Fontf=newFont("宋体",10,FontStyle.Bold); Rectangler=newRectangle(e.Bounds.Top+5,e.Bounds.Left+5,e.Bounds.Right-5,e.Bounds.Height-5); e.Graphics.DrawString(str,f,Brushes.Black,r);} //方法二(此方法为GridView没有设置数据源绑定时,使用,一般使用此种方法) if(this._flag) {if(this.gridV
5、iew1.RowCount==0) {stringstr="没有查询到你所想要的数据!";Fontf=newFont("宋体",10,FontStyle.Bold); Rectangler=newRectangle(e.Bounds.Left+5,e.Bounds.Top+5,e.Bounds.Width-5,e.Bounds.Height-5); e.Graphics.DrawString(str,f,Brushes.Black,r);}}} 9、如何显示水平滚动条?或 设置this.gridView.OptionsView.ColumnAutoWidth=false
6、; .....列表宽度自适应内容 gridview1.BestFitColumns(); 10、如何定位到第一条数据/记录? 设置this.gridView.MoveFirst() 11、如何定位到下一条数据/记录?设置this.gridView.MoveNext() 12、如何定位到最后一条数据/记录? 设置this.gridView.MoveLast() 13、设置成一次选择一行,并且不能被编辑 this.gridView1.FocusRectStyle=DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyl
7、e.RowFocus; this.gridView1.OptionsBehavior.Editable=false; this.gridView1.OptionsSelection.EnableAppearanceFocusedCell=false; 14、如何显示行号? privatevoidgvPayList_CustomDrawRowIndicator(objectsender,DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgse)