devexpress 的 grid 增加行刪除功能

2022-01-18 16:51:40 字數 2134 閱讀 7651

1、新建usercontrol起名為    contextmenumodule,示例**如下:

"

main.usercontrols.evidencepackagelist

"x:name="contextmenumodule"xmlns="

"xmlns:x="

"xmlns:mc="

"xmlns:d="

"xmlns:local="

clr-namespace:main.usercontrols

"xmlns:dx="

"xmlns:dxg="

"xmlns:dxb="

"xmlns:dxmvvm="

"xmlns:dxrudex="

"mc:ignorable="d"

d:designheight="

450" d:designwidth="

800" loaded="

usercontrol_loaded

">

2、建乙個 grid  前台**示例如下:

"

grid

" selecteditemchanged="

grid_selecteditemchanged

" mousedoubleclick="

grid_mousedoubleclick

" contextmenu="

" horizontalalignment="

stretch

" verticalalignment="

stretch

">

"row" x:name="

gridview

" allowcolumnfiltering="

false

" allowscrollanimation="

true

" showgrouppanel="

false

" showgridmenu="

gridview_showgridmenu

">

"refresh

"content="重新整理"

itemclick="

refresh_click

"command="

"commandparameter="

" />

"deleterow

"content="刪除"

command="

"commandparameter="

" />

"id" horizontalheadercontentalignment="

left

" fixedwidth="

true

" fieldname="

id" width="

*" visible="

false

" />

"名稱" horizontalheadercontentalignment="

left

" fixedwidth="

true

" fieldname="

name

" width="

*" />

3、後台加立事件

public

static

readonly dependencyproperty cellmenuinfoproperty = dependencypropertymanager.register("

cellmenuinfo

", typeof(gridcellmenuinfo), typeof(evidencepackagelist), new frameworkpropertymetadata(null

));

public icommand deleterow

public

evidencepackagelist()

public

gridcellmenuinfo cellmenuinfo

set }

備註: 

command=""   裡的指的是當前使用者控制項的名稱。

DevExpress彈框 右鍵選單 Grid的使用

很重要!dev為了區分winform的命名,會把一些新新增的屬性放在properties物件裡!找不到想要的屬性,記得到裡面找找哦!在這裡假設我們的資料來源是db.list 在這裡我主要講述關於資料來源繫結的方式。下拉框的繫結需要三個 資料來源,顯示值,隱藏值 this.combobox.displ...

DevExpress的XtraReport使用積累

1 form裡新增printingsystem和printbarmanager控制項。工程中另行建立xtrareport class,此專案為報表實體,其上可以insert band report header出現在第一頁開頭,report footer出現在最後一頁,detail頁內容,pager...

DevExpress公司的xtraGrid控制項

提交當前行的修改 using devexpress.xtragrid using devexpress.xtragrid.views.base using system.data.common public void updatedatasource gridcontrol grid public ...