Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to allow Return in cell editor (textbox)

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
Benedikte



Joined: 13 Aug 2014
Posts: 2

PostPosted: Wed Aug 13, 2014 10:58 am    Post subject: How to allow Return in cell editor (textbox) Reply with quote

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… Shocked

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Aug 14, 2014 7:57 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Benedikte



Joined: 13 Aug 2014
Posts: 2

PostPosted: Thu Aug 14, 2014 8:05 am    Post subject: Works like a charm!!! Reply with quote

Very Happy This made my day
Thank you
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group