Datatable中的某行某列能不能添加一个下拉框的控件

 我来答
miniappYoh44tFFDbwZi
2016-01-22 · 请开发者输入账号签名
miniappYoh44tFFDbwZi
采纳数:14074 获赞数:18289

向TA提问 私信TA
展开全部
Repositories and Repository Items
The editors of the DevExpress Editors Library can be used to perform in-place editing in the container controls provided by DevExpress. This topic describes the mechanism used to assign in-place editors to container controls.
Online Video
WinForms Grid: The Repository Editor
Editor Repositories and Repository Items

Each editor which can be used for in-place editing has a Properties property which stores the settings and event handlers that correspond to this editor. This property represents an instance of the class derived from the RepositoryItem class. For instance, a date editor (DateEdit) provides the DateEdit.Properties property of the RepositoryItemDateEdit type.
Objects derived from the RepositoryItem class are called Repository Items. As you can see a repository item is a part of an editor (the repository item can be accessed via the editor's Properties property). But repository items can also exist as standalone objects.
You should create specific repository items as standalone objects to embed editors of particular types into container controls (XtraGrid, XtraVerticalGrid, Tree List and XtraBars). For instance, you need to create a RepositoryItemButtonEditobject to embed a ButtonEdit in a container control. See the Editors document for a list of the editors that can be used in-place and their corresponding repository items.
Enough information is contained in a repository item to create a fully functional editor. For instance, when an end-user clicks a cell within the Grid Control to activate an in-place editor, the grid does the following:
First, it looks for the repository item which is assigned to this cell.
It then creates an editor which corresponds to this repository item based upon the information provided by this item.
Then all the settings and event handlers of the source repository item are copied to the editor's Properties property.
Finally the editor is displayed within the clicked cell. When an end-user leaves the cell the editor is automatically destroyed but the source repository item isn't affected.

To use a repository item in a container control it must be added to this control's internal editor repository or to anexternal editor repository:
A control's internal repository.
Repository items added to this repository can only be used within this control and cannot be used within other container controls.
For EditorContainer descendants (XtraGrid, XtraTreeList, and XtraVerticalGrid) the internal editor repository can be accessed via the EditorContainer.RepositoryItems property. For ComponentEditorContainer descendants (XtraBars) use the ComponentEditorContainer.RepositoryItems property instead.
An external repository.
An external editor repository can be bound to multiple container controls within the same application. Repository items that are added to this repository can be shared between all the controls that are bound to it.
An external repository is represented by a PersistentRepository component. To bind an external repository to a container control, use the EditorContainer.ExternalRepository property. TheComponentEditorContainer.ExternalRepository property should be used for container components.
Containers can use repository items stored within both repositories. Thus, the entire collection of repository items that are available is comprised of the items stored within the internal repository and the items added to the bound external repository, if any.
Repository items created within containers at design time are automatically added to internal repositories. Items created via code should be added to repositories manually.
Example

The following code shows how to assign a DateEdit editor which will be used for in-place editing to a column in the XtraTreeList. First, a repository item (RepositoryItemDateEdit) corresponding to the required editor is created and added to the control's internal repository. Then this repository item is bound to a specific column:

C#

VB

RepositoryItemDateEdit riDateEdit = new RepositoryItemDateEdit();
// Customize the item...
// Add the item to the control's internal repository.
treeList1.RepositoryItems.Add(riDateEdit);
// Bind the item to the control's column.
treeList1.Columns["Start Date"].ColumnEdit = riDateEdit;

The result is shown in the image below:

Design-Time Tools

All the container components and controls provided by DevExpress have their own facilities (which are all very similar) for managing their internal repository at design time. The following screenshots demonstrate how to add editors to a grid control's internal repository. This is done using the grid control's designer dialog.

The list displays all the repository items which reside within the grid's internal repository. To add an editor to the repository, press the down arrow near the Add button. This opens the dropdown list which allows you to specify the type of the repository item:

External repositories (PersistentRepository components) provide a similar designer for their collection of repository items. To invoke the designer, press the ellipsis button which corresponds to the EditorsRepositoryBase.Items property.

Once repository items have been added to the desired collections and customized as required, you should bind them to particular visual elements (columns, data cells, etc). To learn how to do this, please refer to the documentation provided for the container control or component you are using.
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式