Link to home
Create AccountLog in
Avatar of basilhs_s

asked on

Delete on EditMask Column in DataWindow moves cursor right

Hi all

I have a string type EditMask column in DataWindow
When I delete characters cursor moves to right (to end of column)
How can I keep cursor in the begining of column?

Thanks in advanced
Avatar of kmanoharnaik
Flag of India image


Cursor does not move to the end position when you delete usingg <DEL> key,

anyway you can trace it in editchanged event or keydown event of datawindow.

Please let me know the exact flow you are doing/code you have written.

Avatar of basilhs_s


I have a char column.
Style Type is Edit Mask in Edit Tab
I set Mask with this command : dw_1.object.rent_rma_code.EditMask.Mask = gvl_diadromhformat
Mask value is : '###-####-###' and it is parametric
Works fine unless Deletion. i don't want cursor to move to right when I delete
You can try it with Date columns with edit mask. Also cusror moves right when press Del
Only in numeric columns with edit mask cursor stays in same position.
Any Clue


i tried with sample datawindow, in which i had kept a column of EDITMASK of string type,

in run mode, when i deleter cursor stays at the same position.

please check in dw keydown event with keycode as Del!....for every keystroke, change the focus of the control and get back the focus to the field.
its roundabout but i think it works out.

please let me know if it doesnt.

It doesn't work
Every char column with this ###-####-### edit mask I use , has the same response. Move the cursor right in Delete.
Only numeric edit mask columns have the response i I want
Date columns also do the same
If you try and your cursor don't move right this might be something in regional settings.
Try a date column edit mask in datawindow


the problem lies with edit mask style i.e. '-'(hyphen), do you need the mask in similar fashion?
if hypehn is taken out, works fine.

I tried a space instead of '-'. Same response.Cursor moves right
You mean without delimiter? Like '#########' ?
yes, provided your requirement matches.
I need a delimiter
'-'  , '.' , ' '
Customer want it

Any clue?
Hi Basil,

I doubt I saw your question very late.

When you delete a character in an Edit Mask column, the cursor moves to the next character position. This behaviour is expected and it ease deletion of characters. But if you have 5 characters in the edit mask and you delete first character, cursor will not move to END of the word (that is 6 here), it only moves to second position. If this is your exact problem, you may use below logic to bring the cursor back to the same position as it was before the DEL key was pressed.

Create an event, say ue_setposition, for the datawindow in question with one integer argument ai_position.
Place below code in this event. It will set the cursor position to desired location in the current edit control in the datawindow.
this.SelectText (ai_position, 0)

Open in new window

Create a new event, say ue_keydown, for the datawindow by assigning event id "pbm_dwnkey" which will be triggered when any key is pressed in the datawindow. Place below code in this event.
If This.GetColumnName() = "c00001" Then //Change to your column name
	If key = KeyDelete! Then Post Event ue_setposition (This.Position())
End If

Open in new window

Remember to change the columnn name in above code ("c00001") to your column name. Hope this helps.

Hi Harish

It doesn't work
Event doesn't fire att all

Which event is not fired? ue_keydown or ue_setposition?
Please verify below points:
1. ue_keydown event is created on the datawindow, and not on the window.
2. pbm_dwnkey event id is associated with this event.
3. Put a breakpoint and debug or put a message box as first line in this event to make sure if the event is fired.
4. Check if you have mentioned the column name correctly. Please note that column name comparison is case sensitive.

These are the things I can think of now. I dont see any reason why an event with eventid pbm_dwnkey will not be triggered when a key is pressed in the datawindow.

Hi Harish

I checked in an other project
Event fires but it deletes only the one char in the cursor position and nothing else. Other characters dont move left. I can delete only one character. I use PB 11.5

Avatar of Harish Varghese
Harish Varghese
Flag of India image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account