Home > Net >  At VB.Net, please how to trigger the DataGridView. CellValidating event
At VB.Net, please how to trigger the DataGridView. CellValidating event

Time:11-22

Public Event EventCellValidating As DataGridViewCellValidatingEventArgs (e) 'custom events

Public Sub StartEvent As DataGridViewCellValidatingEventArgs (e) 'trigger process
RaiseEvent EventCellValidating (e) 'trigger
End Sub

The problem is that the parameter: DataGridViewCellValidatingEventArgs
Dim Args1 AS DataGridViewCellValidatingEventArgs, it is null, it has no attributes and methods, how to provide event?

Please everybody to help! Have reference to many online, don't provide a reference example again let me thinking, also don't give the C language, trouble directly solve the problem, if you can, complete written statements, thank you thank you again!

CodePudding user response:

Even rewriting method in a derived class: OnCellValidating, but the problem is still the parameters: DataGridViewCellValidatingEventArgs, how to assign a value?
Protected Overrides Sub OnCellValidating As DataGridViewCellValidatingEventArgs (e)
MyBase. OnCellValidating (e)
End Sub

Hope to answer!

CodePudding user response:

Why to capture the control of cell to verify events? With holding is bound to the datagridview should not go to tube datagridview, directly to validate the data itself, using DataAnnotations relevant methods directly on the basis of the binding class verification, or use the Inotifypropertychanged, add your own validation method in method,

CodePudding user response:

Don't understand what is said? After cell input validation, the simple things, even myself writing this validation events, then trigger a also is very simple:
 
AddHandler data list.
CellValidating, AddressOf input validationSub input validation (sender As Object, e As DataGridViewCellValidatingEventArgs)
Yeah yeah If e.F ormattedValue="https://bbs.csdn.net/topics/" Then MessageBox. Show (" determine add?" , "hint" MessageBoxButtons. YesNo)
End Sub

CodePudding user response:

Thanks for reply! But didn't get the treatment method of the problem itself,
To 3 floor is event binding process, what I want is how to trigger the event, such as how in other programs by this method is called: OnCellValidating, triggering the incident,
The second floor is provided to skip the question way,
. Ask questions several times in this game, so from the beginning in anticipation of the result, but still want to ask, how to trigger the DataGridView. CellValidating event?

CodePudding user response:

The only way is to make CurrentCell=DbNull. Value, triggering the event,

CodePudding user response:

Not clear train of thought? Custom event parameters can write like that, however the parameters passed how to obtain? Need to have registered event to get parameters,

CodePudding user response:

Forced to give a personal advice, less than, don't take the datagridview when input device,

CodePudding user response:

The seventh floor, AddHandler AddressOf statements, the event parameters: DataGridViewCellValidatingEventArgs provide custom events (the following items 2, 3), this I know, but inside the trigger this event program (the following item 1), how to provide the parameter?
1. The triggering event program
2. The event
3. The custom event handler
For example: CellEnter, binding the custom event handler, and outside also can use New DataGridViewCellEventArgs, then direct call the custom event handler, but don't know how to create this DataGridViewCellValidatingEventArgs,

The eighth floor, datagridview is not facing the user USES the output of the input control?

CodePudding user response:

The meaning of the eighth floor, should is to point to inside the program, when not processing control, don't use controls to access the internal program! Thank you, after there is a better way, can replace,
  • Related