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

specialized cell editor

Could someone suggest an approach to cell behavior I need. It has some of the flavor of a mask, and some not. I''m not adverse to writing a custom renderer, but I''d hate to do that for nothing, if what I need can be done in vanilla cell types and events. Here''s the behavior. 1. When the cell is blank (ie Cell Value = null, or the string.Empty or cell.text="*") the cell should display "*". I don''t need all these conditions, any one is sufficient. 2. When the user clicks on the cell and types a digit, the "*" should be replaced with the digit, and the cell should behave like a mask edit box with a numeric mask that contains literals -- e.g. "9.## mm" 3. The cell must respect a specified minimum value (typically zero) and an optional maximum value. 4. If the user blanks out the entry with any of the customary techniques (delete, backspace keys , selectall/delete, the cell should revert back to "*" My first idea was to use the MaskEdit cell with a blank mask, and then in the validatingString event, detect the first digit entry, and then set the mask from inside the event, but that seems to swallow the first digit. (I''m sure there are rules about what you can change in a cell during an event...) Am I missing something really simple?

2 Replies

ST stanleyj Syncfusion Team January 23, 2006 09:18 PM UTC

Hi Ralph, This KnowledgeBase article ''How do I put a cell in overstrike mode so that the characters get replaced instead of being inserted as you type.'' may help you. Here is a code that does a little of what you need. private void gridControl1_CurrentCellKeyPress(object sender, KeyPressEventArgs e) { GridTextBoxCellRenderer cr = this.gridControl1.CurrentCell.Renderer as GridTextBoxCellRenderer; if(e.KeyChar != Convert.ToChar(Keys.Back) && cr.TextBox.SelectionLength == 0) { cr.TextBox.SelectionLength = 1; //Programatically selecting One char. if(cr.TextBox.SelectedText == ".") cr.TextBox.SelectionStart += 1; //Skipping the dot } } For the rest I think you need to do some sort of custom validation. Refer this article. Best regards, Stanley


RA ralph_lachance January 24, 2006 12:14 PM UTC

Stanley, Thanks for the suggestions. I think you helped point me in the right direction. ''best -r

Loader.
Live Chat Icon For mobile
Up arrow icon