We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

NumericUpDown cell invalidating/refreshing

Thread ID:

Created:

Updated:

Platform:

Replies:

5736 Jul 16,2003 05:43 AM UTC Jul 18,2003 01:28 AM UTC WinForms 4
loading
Tags: GridControl
Nick Pasko
Asked On July 16, 2003 05:43 AM UTC

I use NumericUpDown cell to define some numeric info for my button-hooked function. When i click a button, i read this cell's text to get this numeric info, but if this cell is being edited at the moment, it takes an old value, and sets focuss off and refreshes the text only after my function completes its work. How do i invalidate/refresh/redraw a cell manually during run-time?

Administrator [Syncfusion]
Replied On July 16, 2003 08:15 AM UTC

I suspect the button you are clicking is on a toolbar. If you click a button on the form, then you would get the new value you expect. But if you click a button on a toolbar, you get the old value. The reason is with the CauseValidation architecture of the .NET controls. If focus moves from one control to another, the target control indicates whether the old control should fire its validation events through the new controls' CauseValidation property. A toolbar button does not cause validation, but a button on a form does (unless you change its property). Attached is a little sample. If you change the numericupdown cell, and then click on the button on the form, the new value is shown in the textbox. If you click on the button on the toolbar, the old value gets shown (even though the same code is used to show both values). One way around this problem, is to make your toolbar force the validation by calling the form's Validate method. The sample has commented code that shows this. Does this explain what you are seeing?

Nick Pasko
Replied On July 17, 2003 03:41 AM UTC

Well, that was indeed a useful info, but what i really have is a button IN the grid. The only control on my form is a GridControl with a NumericUpDown, ButtonCell, FormulaCell and some TextCells on it. As far as I understand, the ButtonCell does not force the focused control to validate itself, so how do i force it to validate myself? I could force a form validation, but it is not the best solution, as you surely understand.

Administrator [Syncfusion]
Replied On July 17, 2003 06:37 AM UTC

If the pushbutton is in the grid itself, clicking it does initiate a validation sequence, BUT the pushbuttonclick event is fired before the validation is completed. This is why the old value is still in the grid in your pushbuttonclick handler. One solution would be to go ahead and commit the changes to the current cell at the start of your pushbuttonclick handler(the currentcell is still the old cell at this point).
private void gridControl1_PushButtonClick(object sender, GridCellPushButtonClickEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;

	if(cc.Renderer is GridNumericUpDownCellRenderer
		&& cc.IsModified)
	{
		cc.ConfirmChanges();
	}
	
	//do your work....
}


Nick Pasko
Replied On July 18, 2003 01:28 AM UTC

Thanks a lot!

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;