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.
Unfortunately, activation email could not send to your email. Please try again.

Canceling user input . .

Thread ID:

Created:

Updated:

Platform:

Replies:

38296 Dec 9,2005 09:22 AM Dec 10,2005 11:14 AM Windows Forms 9
loading
Tags: GridControl
Adam K.
Asked On December 9, 2005 09:22 AM

What is the recommended way if a user types in a piece of data and i am catching it on SaveCellInfo and i want to discard it and put back the old value that was previously there. If i just return it seems to keep the value until i put my mouse over the cell and then it returns to the old value. (because QueryCellInfo gets fired again) I then thought to force a refresh in the SaveCellInfo callstack. Do i need to force a refresh on the cell to have querycellInfo get called. Is forcing a refresh on the callstack of SaveCellInfo dangerous. thks, ak

Administrator [Syncfusion]
Replied On December 9, 2005 09:49 AM

Usually, user input validation is done by handling the grid.CurrentCellValidating event. There, you can get the proposed value using grid.CurrentCell.Renderer.ControlText, and if it is not valid, set e.Cancel = true. This is raised before SaveCellInfo.

Adam K.
Replied On December 9, 2005 10:10 AM

this event doesn''t give you a rowIndex and a colIndex like the SaveCellInfo.. how do i figure out this info ?? thks, ak >Usually, user input validation is done by handling the grid.CurrentCellValidating event. There, you can get the proposed value using grid.CurrentCell.Renderer.ControlText, and if it is not valid, set e.Cancel = true. This is raised before SaveCellInfo.

Administrator [Syncfusion]
Replied On December 9, 2005 10:41 AM

grid.CurrentCell.RowIndex and grid.CurrentCell.Colindex.

Adam K.
Replied On December 9, 2005 10:55 AM

Of course . .Ok i an now listening to this new event. Here is a follow up question. I have a scenario where i check the value in the CellValidating event callstack and i want to change it before i send it to the SaveCellInfo event. For example, if someone types in an abbreviation, i have mapping code to change the value (I was previously doing this in the SaveCellInfo event) but now that i have to move this to the CellValidation event to detect bad inputs, i need a way to update the entered value and pass it to the savecellinfo event. Any ideas? thks, ak >grid.CurrentCell.RowIndex and grid.CurrentCell.Colindex.

Administrator [Syncfusion]
Replied On December 9, 2005 10:59 AM

In CurrentCellValidating, if you want to change teh string that will appear in the cell, you can set: grid.CurrentCell.Renderer.Control.Text Notice this is a difference property than the one that gave the proposed value.

Adam K.
Replied On December 9, 2005 11:16 AM

perfect . . >In CurrentCellValidating, if you want to change teh string that will appear in the cell, you can set: > >grid.CurrentCell.Renderer.Control.Text > >Notice this is a difference property than the one that gave the proposed value.

Adam K.
Replied On December 9, 2005 06:13 PM

if you change the grid.CurrentCell.Renderer.Control.Text in the CurrentCellValidating event to the new value, the cursor goes to the front of the cell. this is normally not noticable but if the SaveCellInfo event has an expensive operation then it Is there anyway to keep it at the end where it should logically stay. This is easily reproducable in your example if you add a SaveCellInfo event and do something in a long loop. thks, ak >perfect . . > >>In CurrentCellValidating, if you want to change teh string that will appear in the cell, you can set: >> >>grid.CurrentCell.Renderer.Control.Text >> >>Notice this is a difference property than the one that gave the proposed value.

Administrator [Syncfusion]
Replied On December 9, 2005 07:22 PM

After setting the value in Control.Text within CurrentCellValidating, try setting the cursor position. GridTextBoxControl tb = this.gridControl1.CurrentCell.Renderer.Control as GridTextBoxControl; tb.SelectionLength = 0; tb.SelectionStart = tb.TextLength; tb.Refresh();

Adam K.
Replied On December 10, 2005 11:14 AM

thks . . >After setting the value in Control.Text within CurrentCellValidating, try setting the cursor position. > >GridTextBoxControl tb = this.gridControl1.CurrentCell.Renderer.Control as GridTextBoxControl; >tb.SelectionLength = 0; >tb.SelectionStart = tb.TextLength; >tb.Refresh(); >

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.

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.

;