以编程方式访问网格控件中的按钮 DevExpress
我想启用/禁用网格控件每一行中的按钮。我不确定如何通过代码访问它。我认为这将是 GridView1 方法......
I wanna enable/disable a button found in every row of my grid control. I am not sure how I can access it through code. I would think it would bein the GridView1 methods.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过处理 ShowingEditor 事件来禁用该按钮(或者更好的是,禁用特定单元格的整个编辑)...然后您可以检查其他列的值,然后根据您的意愿取消该单元格的编辑。下面是示例程序的一些代码,向您展示了具体的操作方法:
这是一个非常简单的程序。您必须假设您的按钮编辑列名为 gridButtonCol...我正在测试为此示例创建的 MyData 类的 Even 列的值,您可以执行任何您想要的操作,并在此处检查您喜欢的任何条件。
如果您设置 ShowingEditor 事件的 CancelEventArgs 的 e.Cancel 属性,则单元格将不可编辑,按钮编辑器将不会响应用户单击...
You can disable the button (or better yet, the entire editing of a specif cell) by just handling the ShowingEditor event... You can then inspect the values of other columns and then cancel the editing of that cell depending on your wishes. Here goes some code for a sample program that shows you exactly how to do that:
This is a pretty simple program. You must assume your button edit column is named gridButtonCol... I'm testing the value of the Even column of the MyData class I've created for this sample, you can do whatever you want and check whichever condition you like here.
If you set the e.Cancel property of the CancelEventArgs of the ShowingEditor event, the cell won't be editable and the button editor won't respond to user clicks...