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. Image for the cookie policy date

NumericUpDown cell invalidating/refreshing

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?

4 Replies

AD Administrator Syncfusion Team 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?

NP Nick Pasko 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.

AD Administrator Syncfusion Team 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)
	//do your work....

NP Nick Pasko July 18, 2003 01:28 AM UTC

Thanks a lot!

Live Chat Icon For mobile
Up arrow icon