HOW TO SET A NEW VALUE INTO A COLUMN OF CURRENT CELL
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!!!!
SIGN IN To post a reply.
4 Replies
PM
Piruthiviraj Malaimelraj
Syncfusion Team
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
TR
Truong
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.
TR
Truong
November 10, 2016 08:44 AM UTC
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
PM
Piruthiviraj Malaimelraj
Syncfusion Team
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
SIGN IN To post a reply.
- 4 Replies
- 2 Participants
-
TR Truong
- Nov 9, 2016 09:34 AM UTC
- Nov 11, 2016 12:55 PM UTC