DevExpress GridColumn最大值

时间:2016-02-02 15:02:21

标签: c# devexpress

我在我的项目中使用DevExpress(WindowsForms c#),我的代码中有GridColumn对象。我想设置类似MaxValue属性的东西来设置单元格的值限制。我想阻止用户放置任何比我指定的值更高的值。也许有人可以帮助我吗?:)

1 个答案:

答案 0 :(得分:1)

I think what you want is an In-Place Editor Repository.

From your Grid designer, go to the "Repository" menu item, "In Place Editor Repository," and create a new control -- a SpinEdit sounds like the right choice based on what you described.

The control default name, in this case will be repositoryItemSpinEdit1.

Back on the "Main" menu item, "Columns," select the relevant column(s) and go to the property ColumnEdit, select the drop-down and pick "Existing Items," repositoryItemSpinEdit1.

Now, within your form code, you can set whatever limits you want on the repository item. This is a really crude example, but it should serve as an illustration of what can be done:

if (userName == "Joe")
    repositoryItemSpinEdit1.MaxValue = 50;
else if (userName = "HamBone")
    repositoryItemSpinEdit1.MaxValue = 500000;
相关问题