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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

HOW TO SET A NEW VALUE INTO A COLUMN OF CURRENT CELL

Thread ID:

Created:

Updated:

Platform:

Replies:

127335 Nov 9,2016 09:34 AM UTC Nov 11,2016 12:55 PM UTC WinForms 4
loading
Tags: GridListControl
Truong
Asked On November 9, 2016 09:34 AM UTC

I want to set value of conlai_Label text to currentcell of gridlistcontrol but it do not work

gridListControl1.Grid.CurrentCell.BeginEdit();        

gridListControl1.Grid[gridListControl1.Grid.CurrentCell.RowIndex, 2].Text = ConLai_Label.Text;

gridListControl1.Grid.CurrentCell.EndEdit();

THANK YOU FOR HELPING ME!!!!

Piruthiviraj Malaimelraj [Syncfusion]
Replied On November 10, 2016 08:33 AM UTC

Hi Truong, 

Thanks for the update. 

In order to change the particular cell value , you can use QueryCellInfo event. The reason for using the QueryCellInfo event to change the text of the cell has been provided in the forum - 54541. Please make use of the below code, 

Code example: 
this.gridListControl1.Grid.QueryCellInfo += new GridQueryCellInfoEventHandler(Grid_QueryCellInfo); 
void Grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) 
    if (e.RowIndex == 5 && e.ColIndex == 2) 
    { 
        e.Style.Text = this.textBox1.Text; 
    } 
Sample link: 
 
Note: 
The current cell value can’t be changed permanently  using QueryCellInfo event while clicking the cell ,since the QueryCellInfo event is triggered for every cell at run time. So the cell value will be changed to its old value when current cell is moved to another cell. 

Regards, 
Piruthiviraj

Truong
Replied On November 10, 2016 08:41 AM UTC

Thank you but it still not working with current cell , it only work with row == 5 , when i replace with gridListControl1.Grid.CurrentCell.RowIndex , it not working as well.


Truong
Replied On November 10, 2016 08:44 AM UTC

https://fb-s-d-a.akamaihd.net/h-ak-xap1/v/t1.0-0/p280x280/14938338_1900265203528967_7584988270857045369_n.jpg?oh=70fc0eae3c1ed2e72490259b07676dff&oe=5895C1B3&__gda__=1486163596_a2854c2a76f67771bcea355068fb73c8

I want to set this label.text into current row when i click on button

The Process is : click on a row => show data to the right , change the text , click button save to chosen row



Piruthiviraj Malaimelraj [Syncfusion]
Replied On November 11, 2016 12:55 PM UTC

Hi Truong, 

Thanks for the update. 

We could able to understand your scenario. By default,GridListControl is used to display the datasource values and its cell’s type is “Static”. So GridListControl does not allowed to edit the cell values. If you want to change the cell text while clicking, QueryCellInfo event can be used ,but when current cell has lost focus, it retrieves the original value from underlying datasource. It is the default behaviour.  

To change the cell value of the current cell,  change or update that value in datasource.  So that the changed value will reflects in GridListControl.  Please make use of the below code. 
 

Code example: 
this.gridListControl1.Grid.CellClick += new GridCellClickEventHandler(Grid_CellClick); 
int rowIndex; 
string Column; 
void Grid_CellClick(object sender, GridCellClickEventArgs e) 
    GridStyleInfo style = this.gridListControl1.Grid[e.RowIndex,e.ColIndex]; 
    this.textBox1.Text = style.Text; 
 
    rowIndex = e.RowIndex; 
    Column = this.gridListControl1.Grid[0,e.ColIndex].Text; 
} 
private void btn_text_Click(object sender, EventArgs e) 
    //Save the value in datasource. 
    table.Rows[rowIndex][Column] = textBox1.Text; 
 
Sample link: 

Regards, 
Piruthiviraj

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

;