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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Cell value on double click row

Thread ID:

Created:

Updated:

Platform:

Replies:

129237 Mar 6,2017 09:43 PM UTC Mar 8,2017 07:30 AM UTC WinForms 3
loading
Tags: GridGroupingControl
Josip Pejakovic
Asked On March 6, 2017 09:43 PM UTC

Hi!

How to get value from specific row in gridgroupingcontrol when user makes double click on row? Is it possible?

I had tried with this:

 private void gridKumulativno_TableControlCellDoubleClick(object sender, GridTableControlCellClickEventArgs e)
        {
            Console.WriteLine(SelektiraniZapis(grid, "IDVozilo").ToString());
         }  

 private object SelektiraniZapis(string nazivPolja)
        {
            object o = null;

            if (grid.Table.CurrentRecord != null)
            {
                Record r = grid.Table.CurrentRecord;
                int col = grid.TableControl.CurrentCell.ColIndex;
                o = r.GetValue(grid.TableDescriptor.Fields[nazivPolja]);
            }

            return o;
        }

But nothing happens.

Arulpriya Ramalingam [Syncfusion]
Replied On March 7, 2017 10:32 AM UTC

Hi Josip,

Thanks for your interest in Syncfusion products.

The recommended way to get the current record value onTableControlCellDoubleClickevent is by getting the style of the current cell usingGetTableViewStyleInfo()methodby passing theRowIndexandColumnIndexof the clicked cell. Please make use of the below code and sample,

Code Snippet

//Event Triggering

this.gridGroupingControl1.TableControlCellDoubleClick += GridGroupingControl1_TableControlCellDoubleClick;

//Event Customization
privatevoidGridGroupingControl1_TableControlCellDoubleClick(objectsender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgse)
{
//To pass the column index and row index of current record
intcolumnIndex = e.Inner.ColIndex;
introwIndex = e.Inner.RowIndex;
Console.WriteLine(GetRecordValue(rowIndex, columnIndex));

}

//To Get the cell value of current record
privatestringGetRecordValue(introwIndex,intcolumnIndex)
{
stringcellValue =string.Empty;
//To get the style of current cell
GridTableCellStyleInfostyle =this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(rowIndex, columnIndex);
if(style.TableCellIdentity !=null&& (style.TableCellIdentity.TableCellType ==GridTableCellType.RecordFieldCell
|| style.TableCellIdentity.TableCellType ==GridTableCellType.AlternateRecordFieldCell))
{
Recordrecord = style.TableCellIdentity.DisplayElement.GetRecord();
//To get the cell value of current cell
cellValue = record.GetValue(style.TableCellIdentity.Column.Name).ToString();
}
returncellValue;

}

Screenshot

Sample Link

http://www.syncfusion.com/downloads/support/forum/129237/ze/CellValue_on_DoubleClick-1221361787

Regards,

Arulpriya


Josip Pejakovic
Replied On March 7, 2017 07:54 PM UTC

Thanks a lot! Very useful example.

In my case I have grid with 5 columns. Last column is not visible to user but I want to get value from this column. Is it possible?

Arulpriya Ramalingam [Syncfusion]
Replied On March 8, 2017 07:30 AM UTC

Hi Josip, 

  

Thanks for your update. 

  

The hidden column’s record cell value can also be retrieved by passing the hidden column name in the Record.GetValue(“HiddenColumnName”) method. In the below sample, Date column is in hidden mode and value can be retrieved by double clicking on a record 

 

Code Snippet 

  

//Event Triggering 

this.gridGroupingControl1.TableControlCellDoubleClick += GridGroupingControl1_TableControlCellDoubleClick; 

//Event Customization 
private void GridGroupingControl1_TableControlCellDoubleClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e) 
{ 
    //To pass the column index and row index of current record 
    int columnIndex = e.Inner.ColIndex; 
    int rowIndex = e.Inner.RowIndex; 
    //Console.WriteLine(GetRecordValue(rowIndex, columnIndex)); 
    MessageBox.Show(GetRecordValue(rowIndex, columnIndex)); 

} 

//To Get the cell value of current record 
private string GetRecordValue(int rowIndex, int columnIndex) 
{ 
    string cellValue = string.Empty; 
    //To get the style of current cell 
    GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(rowIndex, columnIndex); 
    if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell 
        || style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell) 
    { 
        Record record = style.TableCellIdentity.DisplayElement.GetRecord(); 
        //To get the cell value of current cell 
        cellValue = record.GetValue(“Date”).ToString(); 
    } 
    return cellValue;    

} 

  

  

Screenshot 

  

  

  

Sample Link 

http://www.syncfusion.com/downloads/support/forum/129237/ze/Hidden_column_value_on_cell_click-565795347  

  

Regards, 

Arulpriya 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

;