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

Add new row (end table)

Thread ID:

Created:

Updated:

Platform:

Replies:

128990 Feb 20,2017 02:45 PM UTC Feb 22,2017 12:49 PM UTC WinForms 3
loading
Tags: GridControl
Slava
Asked On February 20, 2017 02:45 PM UTC

And another question) How to add a row but in the end, but not to the top of the all inserted

Mohanraj Gunasekaran [Syncfusion]
Replied On February 21, 2017 05:52 AM UTC

Hi Slava,  
  
Thanks for using Syncfusion products.  
  
In order to add the new row at end of the table in GridControl, you can use the GridControl.Rows.InsertRange method. Please make use of the below code and refer the below attached sample  
  
Code Example  
private void addRowsBtn_Click(object sender, EventArgs e)  
{  
    this.gridControl1.Rows.InsertRange(this.gridControl1.RowCount + 1, 1);  
}  
  
  
Sample link: GridControl  
 
Regards,  
Mohanraj G

Slava
Replied On February 21, 2017 07:48 AM UTC

Hi Slava,  
  
Thanks for using Syncfusion products.  
  
In order to add the new row at end of the table in GridControl, you can use the GridControl.Rows.InsertRange method. Please make use of the below code and refer the below attached sample  
  
Code Example  
private void addRowsBtn_Click(object sender, EventArgs e)  
{  
    this.gridControl1.Rows.InsertRange(this.gridControl1.RowCount + 1, 1);  
}  
  
  
Sample link: GridControl  
 
Regards,  
Mohanraj G

Thanks for the answer. But now the problem with filling column
I was here such code:
                    this.checkGrid.Rows.InsertRange(1, 1);
                   
this.checkGrid[1, 1].Text = item.Attribute("text").Value;
                   
this.checkGrid[1, 2].CellValue = item.Attribute("kol").Value;
                   
this.checkGrid[1, 3].Text = item.Attribute("ed").Value;
                   
this.checkGrid[1, 4].CellValue = item.Attribute("cost").Value;
                   
this.checkGrid[1, 5].CellValue = item.Attribute("skidka").Value;
                   
this.checkGrid[1, 6].CellType = GridCellTypeName.FormulaCell;
                   
this.checkGrid[1, 6].CellValue = "=" + "(" + item.Attribute("kol").Value + "*" + item.Attribute("cost").Value + ")" + "*" + "(" + "1" + "-" + item.Attribute("skidka").Value + ")";
                   
this.checkGrid.Refresh();

I changed your decision

                    this.checkGrid.Rows.InsertRange(this.checkGrid.RowCount +1, 1);
                   
this.checkGrid[this.checkGrid.RowCount +1, 1].Text = item.Attribute("text").Value;
                   
this.checkGrid[this.checkGrid.RowCount +1, 2].CellValue = item.Attribute("kol").Value;
                   
this.checkGrid[this.checkGrid.RowCount +1, 3].Text = item.Attribute("ed").Value;
                   
this.checkGrid[this.checkGrid.RowCount +1, 4].CellValue = item.Attribute("cost").Value;
                   
this.checkGrid[this.checkGrid.RowCount +1, 5].CellValue = item.Attribute("skidka").Value;
                   
this.checkGrid[this.checkGrid.RowCount +1, 6].CellType = GridCellTypeName.FormulaCell;
                   
this.checkGrid[this.checkGrid.RowCount +1, 6].CellValue = "=" + "(" + item.Attribute("kol").Value + "*" + item.Attribute("cost").Value + ")" + "*" + "(" + "1" + "-" + item.Attribute("skidka").Value + ")";
                   
this.checkGrid.Refresh();


Lines are added but empty. Without filling (

Mohanraj Gunasekaran [Syncfusion]
Replied On February 22, 2017 12:49 PM UTC

Hi Slava,     
   
Thanks for your update.   
   
We have analyzed your provided code part. If you have used the InsertRange method to add the new row for GridControl, then row count will be increased automatically. So please use the “RowCount” instead of “RowCount + 1” to set the value for new row. Please refer the below code example and attached sample,   
   
Code example   
//Row count is 25   
 this.checkGrid.Rows.InsertRange(this.checkGrid.RowCount +1, 1); //Now row count is 2  
this.checkGrid[this.checkGrid.RowCount +1, 1].Text = item.Attribute("text").Value; //So you have tried to set the value for 27th row. But there is not presenting the 27th row in GridCotnrol   
   
Please modify your code like below   
this.checkGrid[this.checkGrid.RowCount , 1].Text = item.Attribute("text").Value;   
this.checkGrid[this.checkGrid.RowCount, 2].CellValue = item.Attribute("kol").Value;
this.checkGrid[this.checkGrid.RowCount, 3].Text = item.Attribute("ed").Value;
this.checkGrid[this.checkGrid.RowCount, 4].CellValue = item.Attribute("cost").Value;
this.checkGrid[this.checkGrid.RowCount, 5].CellValue = item.Attribute("skidka").Value;
this.checkGrid[this.checkGrid.RowCount, 6].CellType = GridCellTypeName.FormulaCell; this.checkGrid[this.checkGrid.RowCount +1, 6].CellValue = "=" + "(" + item.Attribute("kol").Value + "*" + item.Attribute("cost").Value + ")" + "*" + "(" + "1" + "-" + item.Attribute("skidka").Value + ")";
   
   
Sample link: GridControl   
   
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

;