提交當前行的修改
using devexpress.xtragrid;
using devexpress.xtragrid.views.base;
using system.data.common;
//...
public void updatedatasource(gridcontrol grid)
public void doupdate(dbdataadapter dataadapter, system.data.datatable datatable) catch(exception ex) }
從非繫結資料來源得到資料
private void form1_load(object sender, system.eventargs e)
// returns the total amount for a specific row.
decimal gettotalvalue(columnview view, int rowhandle)
// provides data for the total column.
private void gridview1_customunboundcolumndata(object sender, devexpress.xtragrid.views.base.customcolumndataeventargs e)
執行時繫結到實現ilist介面的資料來源
public class record
public int id }
public string name
set }
public int age
set }
}
arraylist listdatasource = new arraylist();
listdatasource.add(new record(1, "jane", 19));
listdatasource.add(new record(2, "joe", 30));
listdatasource.add(new record(3, "bill", 15));
listdatasource.add(new record(4, "michael", 42));
gridcontrol1.datasource = listdatasource;
gridcontrol1.mainview.populatecolumns();
自定義列:
[c#]
devexpress.xtragrid.views.base.columnview view = gridcontrol1.mainview as devexpress.xtragrid.views.base.columnview;
dialogresult answer = messagebox.show("do you want to create columns for all fields?", "confirmation", messageboxbuttons.yesno, messageboxicon.question);
if (answer == dialogresult.yes)
view.populatecolumns();
else ;
devexpress.xtragrid.columns.gridcolumn column;
view.columns.clear();
for (int i = 0; i < fieldnames.length; i++) }
gridcolumn主要屬性
property
description
gridcolumn.name
設計時定義的列名
gridcolumn.fieldname
繫結到的資料來源中的列名
gridcolumn.absoluteindex
在grid中的絕對位置索引
gridcolumn.columnhandle
指定關聯資料來源列名的標識,它不一定是唯一的,因為乙個資料來源列可以關聯到乙個grid中的多個列.
手動建立band
// obtaining the main view and clearing its bands collection
bandedgridview view = gridcontrol1.mainview as bandedgridview;
view.bands.clear();
// creating the bands layout
gridband bandgeneral = view.bands.add("general info");
gridband bandtechnical = view.bands.add("technical info");
gridband bandengine = bandtechnical.children.add("engine info");
gridband bandtran**ission = bandtechnical.children.add("tran**ission info");
// assigning columns to bands
coltrademark.ownerband = bandgeneral;
colmodel.ownerband = bandgeneral;
colliter.ownerband = bandengine;
colcylinders.ownerband = bandengine;
colspeedcount.ownerband = bandtran**ission;
coltran**ission.ownerband = bandtran**ission;
如何定位和查詢指定列顯示值的行(注意是列的實顯示值,而不是關聯資料來源列值)
using devexpress.xtragrid.views.base;
using devexpress.xtragrid.columns;
// ...
string searchtext = "japan";
// obtaining the focused view
columnview view = (columnview)gridcontrol1.focusedview;
// obtaining the column bound to the country field
gridcolumn column = view.columns["country"];
if(column != null) }
另乙個查詢示例
devexpress.xtragrid.views.base.columnview view = gridcontrol1.mainview as devexpress.xtragrid.views.base.columnview;
view.beginupdate();
try
} finally
將特定編輯框繫結到列
預設的cell編輯框是不可以改變的,即使是在執行時,因為它們是動態建立和登出的。
要想定製,就在設計時修改columnedit吧。
using devexpress.xtraeditors.repository;
//create a repository item for a combo box editor
repositoryitemcombobox ricombo = new repositoryitemcombobox();
ricombo.items.addrange(new string );
//add the item to the internal repository
gridcontrol1.repositoryitems.add(ricombo);
//now you can define the repository item as an in-place column editor
colcity.columnedit = ricombo;
另乙個執行時繫結列編輯框示例
private void gridview1_customrowcelledit(object sender, devexpress.xtragrid.views.grid.customrowcellediteventargs e) }
檢驗錄入資料是否有效
using devexpress.xtragrid.views.grid;
using devexpress.xtragrid.columns;
public bool isvaliddate(int day, int month, int year)
private void gridview1_validaterow(object sender, devexpress.xtragrid.views.base.validateroweventargs e) }
DevExpress的XtraReport使用積累
1 form裡新增printingsystem和printbarmanager控制項。工程中另行建立xtrareport class,此專案為報表實體,其上可以insert band report header出現在第一頁開頭,report footer出現在最後一頁,detail頁內容,pager...
DevExpress面板引用的辦法
procedure tfrmmain.setskin skinnam string var hinst thandle rstream tresourcestream begin hinst loadlibrary allsk.dll if hinst 0 then exit else begin ...
步入DevExpress的使用(VS)
2 找到安裝後devexpress控制項的dll 要使用的dll 路徑是 c program files x86 devexpress 2011.1 components sources devexpress.dll 拷貝到自己需要的地方,以方便專案新增引用時通過 瀏覽 找到 不拷貝也可以,專案引用...