View previous topic :: View next topic |
Author |
Message |
Benedikte
Joined: 13 Aug 2014 Posts: 2
|
Posted: Wed Aug 13, 2014 10:58 am Post subject: How to allow Return in cell editor (textbox) |
|
|
I am using cell editor with textbox as control programmatically. However, I am not able to allow return character to be used to allow lineshift.
It is driving me crazy and I would really appreciate some help…
Code: | CellEditor editor = new CellEditor();
TextBox txbox = new TextBox();
txbox.Multiline = true;
txbox.AcceptsReturn = true;
txbox.WordWrap = true;
editor.Control = txbox;
txbox.Dock = DockStyle.Fill;
editor.InitializeControl+=textEditor_InitializeControl;
editor.DisplayMode = CellEditorDisplayMode.Always;
cellBinding.Editor = editor;
private void textEditor_InitializeControl(object sender, CellEditorInitializeEventArgs e)
{
e.Control.TextChanged += Control_TextChanged;
TextBox txtbox = e.Control as TextBox;
txtbox.AcceptsReturn = true;
txtbox.Multiline = true;
} |
|
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Aug 14, 2014 7:57 am Post subject: |
|
|
The problem is that Virtual Tree uses the Enter key to complete editing. So if you use it for adding line breaks the only way a user can complete an edit would be to tab out of the control. Ctrl-M can be used for adding linebreaks in text boxes (so you could educate your users on this). If you do really want to change the behaviour then it is possible by deriving your own control from VirtualTree and overriding the ProcessEditEnterCmdKey method. By default this calls CompleteEdit(). If you override this method and return false then the enter key should be passed on to the text box. You should however provide some other way for the user to complete editing - or only pass the enter key on when there is a Shift or Ctrl modifier. _________________ Infralution Support |
|
Back to top |
|
|
Benedikte
Joined: 13 Aug 2014 Posts: 2
|
Posted: Thu Aug 14, 2014 8:05 am Post subject: Works like a charm!!! |
|
|
This made my day
Thank you |
|
Back to top |
|
|
|