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

Multi line textbox in the special column question

Hi :

Good day, when I create the gridgroupcontrol, I have one of column (Name : remark and thecell type is texbox), and this column need multi line and need vertical scroll bar. Then I would like to do as below :
1. Define the higher row height on any record cell and allow them resize by user need . 
2. The column [remark] show vertical scroll bar and allow user scroll the text
3. For enter key default behavior is turn right. and at the end of cell will auto move to the first cell of first row (<<-- this part I know how to do). but when the cursor locate in column [remark], Press enter key action will change to line return, Only if the user press tab key. the current cell will move to right.

Can we do that ?

Thanks for your help 

:)

Michael

4 Replies

MK Michael K July 5, 2016 03:14 AM UTC

Hi :

Just provide the code for your reference
 void _InitGrid()
        {
            gcc.TableControl.WantEnterKey = false;
            gcc.Table.DefaultRecordRowHeight = 50;


            gcc.TableDescriptor.AllowNew = true;
            gcc.TableDescriptor.AllowEdit  = true;

            gcc.TableDescriptor.Columns["gv_id"].Width = 10; 
            gcc.TableDescriptor.Columns["gv_id"].HeaderText = "ID";
            gcc.TableDescriptor.Columns["gv_id"].MappingName = "ID";

            gcc.TableDescriptor.Columns["gv_Name"].Width = 500; 
            gcc.TableDescriptor.Columns["gv_Name"].HeaderText = "Name";
            gcc.TableDescriptor.Columns["gv_Name"].MappingName = "cName";
            gcc.TableDescriptor.Columns["gv_Name"].Appearance.AnyRecordFieldCell.AllowEnter = true;
            
            gcc.TableDescriptor.Columns["gv_Name"].Appearance.AnyRecordFieldCell.VerticalScrollbar = true;
            gcc.TableDescriptor.Columns["gv_Name"].Appearance.AnyRecordFieldCell.WrapText = true;


            gcc.TableDescriptor.Columns["gv_Amount"].Width = 300; 
            gcc.TableDescriptor.Columns["gv_Amount"].HeaderText = "Amount";
            gcc.TableDescriptor.Columns["gv_Amount"].MappingName = "Amount";
            gcc.TableDescriptor.Columns["gv_Amount"].Appearance.AnyRecordFieldCell.AllowEnter = false;
            gcc.TableDescriptor.Columns["gv_Amount"].Appearance.AnyRecordFieldCell.WrapText = false;
            gcc.DataSource = SampleData;
      
          gcc.TableModel.ColHiddenEntries.Add (new Syncfusion.Windows.Forms.Grid.GridColHidden (1));
      

        }
void gcc_TableControlCurrentCellKeyDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs e)
        {
            if ((e.Inner.KeyCode == Keys.Tab) && e.TableControl.CurrentCell.ColIndex == e.TableControl.TableDescriptor.Columns.Count
              && (e.TableControl.CurrentCell.RowIndex == e.TableControl.Model.RowCount || e.TableControl.CurrentCell.RowIndex ==2))
            {
             

                gcc.Table.AddNewRecord.SetCurrent();
                gcc.Table.AddNewRecord.BeginEdit();
                gcc.Table.AddNewRecord.EndEdit();
                e.TableControl.CurrentCell.MoveTo(e.TableControl.TopRowIndex - 1, 1,  Syncfusion.Windows.Forms.Grid.GridSetCurrentCellOptions.SetFocus , false);
                e.TableControl.SelectRecords.Clear();
            } 
        }

My design is that, All the column only allow to use tab to turn right, and at the end of column [gv_Amount], if user press tab key, it will return to the first row ,first cell to continue add record
The column[gv_Name] is the multi row textbox, user can type text and press key return allow them all new line in textbox cell.

However, this code have bug, when user locate the column [gv_Amount], and press the enter key, the GCC will add the new row and cursor still locate in the last cell and last row. and I check that user press enter will  not trigger the event (gcc_TableControlCurrentCellKeyDown). Do you have any advice ?

Thanks 

Michael 


AR Amal Raj U Syncfusion Team July 5, 2016 06:24 AM UTC

Hi Michael, 
 
Thanks for using Syncfusion products. 
 
 
 
 
1) Define the higher row height on any record cell and allow them resize by user need . 
 
Row height for any record cell can be set using DefaultRecordRowHeight. Please make use of the below code. 
 
//to set default record row height. 
this.gridGroupingControl1.Table.DefaultRecordRowHeight = 60; 
 
If you want to change the row height of particular row without changing other row height. Please refer to the below kb link. 
 
KB link 
 
 
2)The column [remark] show vertical scroll bar and allow user scroll the text 
In order to show vertical scrollbar for record cells, AnyRecordFieldCell.VerticalScrollbar property has to be enabled. Please make use of the below code. 
 
Code Snippet 
//to show VerticalScrollbar in textbox. 
this.gridGroupingControl1.TableDescriptor.Columns["Description"].Appearance.AnyRecordFieldCell.VerticalScrollbar = true; 
3)For enter key default behavior is turn right. and at the end of cell will auto move to the first cell of first row (<<-- this part I know how to do). but when the cursor locate in column [remark], Press enter key action will change to line return, Only if the user press tab key. the current cell will move to right. 
 
4)press enter will  not trigger the event (gcc_TableControlCurrentCellKeyDown). 
On analyzing the your provided code snippet, you had set WantEnterKey = false. If WantEnterKey is set to false, then the grid will not take account of enter key as key pressed. So actions related to enter key will not be processed. If you want to take account of enter key, WantEnterKey property has to be enabled. 
 
//to enable enter key. 
this.gridGroupingControl1.TableControl.WantEnterKey = true; 
 
Is there any specific reason for disabling WantEnterKey property? 
 
Sample link 
 
Regards, 
Amal Raj U. 



MK Michael K July 5, 2016 02:30 PM UTC

Dear Raj :

Yes, I get it, Thanks for your help. :)


Michael 



AR Amal Raj U Syncfusion Team July 6, 2016 11:24 AM UTC

Hi Michael, 

Thanks for your update. 

We are glad to know that the given solution has solved your query. Please let us know, If you need any further assistance. 

Regards, 
Amal Raj U. 


Loader.
Up arrow icon