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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem with delete a records , and when show dialog then press enter to OK , event in Grid actived

Thread ID:

Created:

Updated:

Platform:

Replies:

131123 Jun 22,2017 07:28 AM UTC Jun 28,2017 04:31 PM UTC Windows Forms 4
loading
Tags: GridGroupingControl
Truong
Asked On June 22, 2017 07:28 AM UTC

Dear everyone !
My video in attach file

In video GGC_DELETE_RECORDS, delete a row when click on button HUY of record 2, currentRecord delete but click on button HUY as the same record (after delete record 2 , record 3 change location to record 2) , event TableControlCellClick not active. The event TableControlCellClick still active when click on button HUY of another record. How to solove this Problem.Here is my code of event TableControlCellClick:

private void grd_R_NhapKho_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)

        {

            if (e.Inner.ColIndex >= 1 && e.Inner.RowIndex >= 3)

            {

                string ncol = grd_R_NhapKho.TableDescriptor.VisibleColumns[e.Inner.ColIndex - 1].Name;

                if (ncol == "HUY")

                {

                    if (grd_R_NhapKho.Table.CurrentRecord["ID_HANGHOA"] != null)

                    {

                        grd_R_NhapKho.Table.CurrentRecord.Delete();

                        grd_R_NhapKho.Table.Reload();

                        grd_R_NhapKho.TableControl.Refresh();

                    }

                }

            }

        }

In video GGC_CHANGE_CURRENT_RECORD, when click on GridList the currentcell go move to rowIndex 1(only happen in the first time focus to GridListControl).How to slove this problem.

In video GGC_ENTER_TWICE, when move to other Row(in this case , when press Enter at the last column of a row, the currentcell will move to next row) , a Lib.Synfusion.Window.Dialog.Confirm will appear, if i click on button Enter, everything go right, but when press Enter, the column of next row move to column 2.
Is when press Enter, it accept to Lib.Synfusion.Window.Dialog.Confirm, both event TableControlKeyUp ? Because in event TableControlKeyUp if press Enter , the CurrentCell column will move to next column.How to slove this problem as press Enter only accpet for Lib.Synfusion.Window.Dialog.Confirm.Here is my event TableControlKeyUp  code :

if (e.Inner.KeyCode == Keys.Enter)

            {

                int n = 1;

                if (e.TableControl.CurrentCell.ColIndex == 1&& _move)

                {

                    if (((List<HangHoa>)gridNguyenLieu.DataSource).Count > 0)

                    {

                        GridTextBoxCellRenderer txtTen = grid_HangHoa_DinhLuong.TableControl.CurrentCell.Renderer as GridTextBoxCellRenderer;

                        Record r = grid_HangHoa_DinhLuong.Table.CurrentRecord;

                        r.SetValue("ID_NGUYENLIEU", gridNguyenLieu.SelectedValue);

                        r.SetValue("TEN_FULL", gridNguyenLieu.Text);

                        r.SetValue("ID_HANGHOA", GetHangHoa());

                        txtTen.TextBox.Text = gridNguyenLieu.Text;

                        _update = true;

                    }

                }

                if (e.TableControl.CurrentCell.ColIndex > 0)

                    n = e.TableControl.CurrentCell.ColIndex + 1;

                if (n == 4)

                {

                    e.TableControl.CurrentCell.MoveTo(e.TableControl.CurrentCell.RowIndex + 1, 1);

                }

                else

                {

                        e.TableControl.CurrentCell.MoveRight();

                }

            }

Thank you for reading and helping me !
Best Regard!




Attachment: GGC_89c29a68.rar

Mohanraj Gunasekaran [Syncfusion]
Replied On June 23, 2017 01:07 PM UTC

Hi Truong, 

Thanks for using Syncfusion product. 

Query 
Solution 
In video GGC_DELETE_RECORDS, delete a row when click on button HUY of record 2, currentRecord delete but click on button HUY as the same record (after delete record 2 , record 3 change location to record 2) , event TableControlCellClick not active. The event TableControlCellClick still active when click on button HUY of another record. How to solove this Problem.Here is my code of event TableControlCellClick: 

By default, GridGroupingControl does have the support for cell button click. So, you can use the TableControlCellButtonClicked event. Please refer to the below code example and the sample, 
 
Code example 
this.gridGroupingControl1.TableControlCellButtonClicked+=gridGroupingControl1_TableControlCellButtonClicked; 
 
void gridGroupingControl1_TableControlCellButtonClicked(object sender, GridTableControlCellButtonClickedEventArgs e) 
{ 
    e.TableControl.Table.CurrentRecord.Delete(); 
} 
 
Sample link: GridGroupingControl 
 
Note: 
If this is different from your requirement, please provide your cell type details for button with your customization. It will be helpful to provide the solution at the earliest. 
 
In video GGC_CHANGE_CURRENT_RECORD, when click on GridList the currentcell go move to rowIndex 1(only happen in the first time focus to GridListControl).How to slove this problem. 
We have checked yours provide video. By your video, you have customized the GridListControl for grid cells. We suspect this issue occur based on your customization. So, please provide the simple sample of modify the above attached sample to reproduce your scenario. It will be helpful to provide the solution at the earliest. 
In video GGC_ENTER_TWICE, when move to other Row(in this case , when press Enter at the last column of a row, the currentcell will move to next row) , a Lib.Synfusion.Window.Dialog.Confirm will appear, if i click on button Enter, everything go right, but when press Enter, the column of next row move to column 2.
Is when press Enter, it accept to Lib.Synfusion.Window.Dialog.Confirm, both event TableControlKeyUp ? Because in event TableControlKeyUp if press Enter , the CurrentCell column will move to next column.How to slove this problem as press Enter only accpet for Lib.Synfusion.Window.Dialog.Confirm.Here is my event TableControlKeyUp  code :
 
By default, MessageBox KeyUp events trigger the Control KeyUp event so obviously GridGroupigControl KeyUp event triggers when press the enter key in Dialog box. In order overcome this scenario, you can check with Focused property in KeyUp event. Please refer to the below code example, 

Code example 
if (e.Inner.KeyCode == Keys.Enter && e.TableControl.Focused) 
{ 
 
    int n = 1; 
 
    if (e.TableControl.CurrentCell.ColIndex == 1 ) 
    { 
       //Your implentation 
    } 
} 

Regards, 
Mohanraj G 
 


Truong
Replied On June 28, 2017 03:24 AM UTC

Dear !
Thank you for reading and helping me.
Query 
Solution 
In video GGC_DELETE_RECORDS, delete a row when click on button HUY of record 2, currentRecord delete but click on button HUY as the same record (after delete record 2 , record 3 change location to record 2) , event TableControlCellClick not active. The event TableControlCellClick still active when click on button HUY of another record. How to solove this Problem.Here is my code of event TableControlCellClick: 
TableControlCellButtonClicked event does not working. My code is in GGC_DELETE_RECORDS.txt in Attach file.
I can delete currentRecord normaly. Problem is after delete currentRecord( example delete a record at index 2 , record of index 3 move to index 2), when i click on button HUY at record index 2(record index 3 move to index 2 after delete) , event TableControlCellClick not active, but event still active when click on button HUY of other index
In video GGC_CHANGE_CURRENT_RECORD, when click on GridList the currentcell go move to rowIndex 1(only happen in the first time focus to GridListControl).How to slove this problem. 
My example code in Attatch file.

Thank you for reading and helping me again
Best Regard !


Attachment: Desktop_5b4b47bd.rar

Truong
Replied On June 28, 2017 07:35 AM UTC

QueryProblem
By default, MessageBox KeyUp events trigger the Control KeyUp event so obviously GridGroupigControl KeyUp event triggers when press the enter key in Dialog box. In order overcome this scenario, you can check with Focused property in KeyUp event. Please refer to the below code example, 

Code example 
if (e.Inner.KeyCode == Keys.Enter &&e.TableControl.Focused) 
{ 
 
    int n = 1; 
 
    if (e.TableControl.CurrentCell.ColIndex == 1 ) 
    { 
       //Your implentation 
    } 
} 
I use you code but e.TableControl.Focused is always false , although I press Enter on a CurrentCell of GGC



Mohanraj Gunasekaran [Syncfusion]
Replied On June 28, 2017 04:31 PM UTC

 
Sorry for the inconvenience caused. 
  
Query 
Solution 
TableControlCellButtonClicked event does not working. My code is in GGC_DELETE_RECORDS.txt in Attach file.
I can delete currentRecord normaly. Problem is after delete currentRecord( example delete a record at index 2 , record of index 3 move to index 2), when i click on button HUY at record index 2(record index 3 move to index 2 after delete) , event TableControlCellClick not active, but event still active when click on button HUY of other index 
We have analyzed your provided code part. You have used the Control type for cells. If you use the control type which has activated in first click so control got the focus. In next click, Control.Click event only works so TableControlCellClick wont be triggered. In order to overcome this scenario, you can manually raise the click for cells using RaiseClick method in Control.Click event. Please refer to the below code example and the sample, 
 
Code example 
this.gridGroupingControl1.TableDescriptor.Columns["Delete"].Appearance.AnyRecordFieldCell.Control.Click += Control_Click; 
 
void Control_Click(object sender, EventArgs e) 
{ 
    GridCurrentCell currentCell = this.gridGroupingControl1.TableControl.CurrentCell; 
    //The below code raise the TableControlCellClick event. 
    currentCell.Renderer.RaiseClick(currentCell.RowIndex, currentCell.ColIndex, new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, Cursor.Position.X, Cursor.Position.Y, 0)); 
}   
 
Sample link: GridGroupingControl 
 
My example code in Attatch file. 
We have analyzed your provided code part, in your code part not related to your mentioned issue and we have tried to reproduce your scenario at our end. But we are unable to reproduce the issue. So, please provide your sample file or modify the above attached sample to reproduce your scenario. It will be helpful to provide the solution at the earliest 
I use you code but e.TableControl.Focused is always false , although I press Enter on a CurrentCell of GGC 
TableControl.Focused property failed when current cell in edit mode because in edit mode current cell act as a TextBox. So, TableControl should not have the focus. In order to overcome this scenario, you can use the TableControlCurrentCellKeyUp event instead of TableControlKeyUp event. Please refer to the below code example and the sample, 
 
Code example 
this.gridGroupingControl1.TableControlCurrentCellKeyUp += gridGroupingControl1_TableControlCurrentCellKeyUp; 
 
void gridGroupingControl1_TableControlCurrentCellKeyUp(object sender, GridTableControlKeyEventArgs e) 
{ 
    //Your implementation 
} 
 
Sample link: GridGroupingControl 
 
 
Regards, 
Mohanraj G. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;