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
close icon

Autodropdown of RichTextEntryPanel

Hi, I derived GridRichTextBoxCellModel and GridCellRendererBase for an own implementation of the rich text dropdown-editor with XP-toolbar (V4.2.0.37). How can I automatically drop down the editor when a user starts to type printable characters after entering the (not dropped down) cell? Regards, Christian

4 Replies

AD Administrator Syncfusion Team June 8, 2006 05:08 AM UTC

Hi Christian, To get the desired behavior, please add the code below in theCurrentCellKeyPress Event. Here is a code snippet. private void gridControl1_CurrentCellKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { GridCurrentCell cc = this.gridControl1.CurrentCell; //your custom cell render ... GridDerivedRichTextBoxCellRenderer cr = cc.Renderer as GridDerivedRichTextBoxCellRenderer; if( cr != null) { cc.ShowDropDown(); } } Regards, Haneef


CL Christian Lützenkirchen June 8, 2006 08:45 AM UTC

Hi Haneef, thank you for your example. The example has two problems: 1. The panel is opend when the tab-key is pressed so I had to filter the tab key. (It was not opened by the left or right key), 2. My bigger problem is that the first character is not shown in the panel. How can I get my panel and how can I send the pressed key? Regards, Christian


AD Administrator Syncfusion Team June 8, 2006 09:13 AM UTC

Hi Christian , Issue 1 : To show the dropdown when the Right/Left key is pressed , You need to handle the CurrentCellKeyDown Event. Here is a code snippet. private void gridControl1_CurrentCellKeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { GridCurrentCell cc = this.gridControl1.CurrentCell; GridRichTextBoxCellRenderer cr = cc.Renderer as GridRichTextBoxCellRenderer; if(cr != null && ( Keys.Right == e.KeyData || Keys.Left == e.KeyData ) ) { cc.ShowDropDown(); e.Handled = true; } } Issue 2: Try this code to check the TabKey pressed in a cell, and assign the pressed Keychar in a richtextbox . Here is code snippet. private void gridControl1_CurrentCellKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { GridCurrentCell cc = this.gridControl1.CurrentCell; GridRichTextBoxCellRenderer cr = cc.Renderer as GridRichTextBoxCellRenderer; int Tabchar = (int)e.KeyChar; if(cr != null && Tabchar != 9) { cc.ShowDropDown(); GridRichTextEntryPanel panel = cr.DropDownContainer.Controls[0] as GridRichTextEntryPanel; if(panel != null) { RichTextBox richBox = panel.ActiveControl as RichTextBox; if( richBox != null) { richBox.Text += e.KeyChar.ToString(); richBox.SelectionStart = richBox.Text.Length; } } } } Let me know if this helps. Best Regards, Haneef


CL Christian Lützenkirchen June 8, 2006 10:38 AM UTC

Hi Haneef, thank you very much. It works fine. I decided not to open then panel für tab, right or left key. Best Regards, Christian

Loader.
Live Chat Icon For mobile
Up arrow icon