c#编辑Datagridview中的SQL Server Management Studio中的数据 [英] c# edit data like in SQL Server Management Studio in Datagridview

查看:98
本文介绍了c#编辑Datagridview中的SQL Server Management Studio中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你点击表格的上下文菜单中的编辑前200行,我希望我的c#program with datagridview几乎像SQL Server Management Studio一样工作。

没有保存-Button并且如果数据是假的,你不能将焦点放在另一行上。



在数据网格视图中从一行留下焦点之前,在C#中进行验证,可以取消焦点松散。像Before_Row_Update之类的东西。 CellValidating不起作用,因为它阻止用户输入不同列中的数据。



示例:两列,都必须填充数据。用户在Col 1中输入值,然后在其他行上点击。现在必须进行验证(错误,因为Col 2为空)并且焦点应保留在Col1中,但用户必须能够将焦点设置在Col 2.如果焦点自动设置为Col 2,则会更好。 br />


我以为我可以使用RowLeaveEvent,但这个事件似乎不可取消。



期待: - )

I want my c# program with datagridview to work almost exaktly like SQL Server Management Studio if you click on "Edit top 200 Rows" in the context menu of a table.
There is no "Save-Button" and you can't put the focus on a other row, if data are false.

Before the focus is left from a row in a datagridview, a verification in C# shall be done, in which the focus loose can be canceled. Something like Before_Row_Update. CellValidating is not working, because it prevents the user from entering data in a different column.

Example: two columns, both have to be filled with data. User enters value in Col 1 and then klicks on other row. Now verification has to be done (error because Col 2 is empty) and the focus shall stay in Col1 but the user must be able to set the focus on Col 2. It would be better if the focus is set automatically to Col 2.

I thought i could use the RowLeaveEvent, but this Event seems not to be cancellable.

Looking forward :-)

推荐答案

我可以想象如果这个事件被取消你可能会遇到的麻烦。对你有好处,它不能。 :-)

这种做法是完全错误的。相反,您应该只标记数据无效(例如,显示一些视觉反馈)。无效数据是无害的,直到您尝试使用它为止。例如,如果您有一些按钮,可以按照数据的使用方式进行处理。在这种情况下,当您检测到数据无效时,请禁用该按钮。或其他。



-SA
I can imagine the trouble you could cause if this event could be cancelled. So good for you it cannot. :-)
This approach is plain wrong. Instead, you should just mark data invalid (say, show some visual feedback). Invalid data is harmless, up to the point you are trying to use it. For example, if you have some button which is handled the way the data can be used. In this case, when you detect that data is invalid, disable that button. Or something else.

—SA


如果RowValidate事件被取消,那么焦点不能设置为另一行。

我还没有看到这个,因为RowLeave在RowValidate之前触发。仍然不知道为什么这是订单。
If the RowValidate Event is canceled, then the focus can't be set to another row.
I haven't seen this, because RowLeave fires before RowValidate. Still don't know why this is the order.


这篇关于c#编辑Datagridview中的SQL Server Management Studio中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆