This is a migrated thread and some comments may be shown as answers.

Example of ibindinglist to add new row in Gridview winforms

1 Answer 86 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rama
Top achievements
Rank 1
Rama asked on 03 Jan 2008, 09:10 AM
please give any example of to add new row in grid view when use the data source toGridview

Regards,
Ramakrishnan S

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 04 Jan 2008, 12:55 PM
Hello Rama,

Thank you for writing. Here is an example which adds a new row in the RadGridView with a BindingList object:

public class Person  
{  
    private string name;  
    private DateTime? dateOfBirth;  
 
    public string Name  
    {  
        get { return this.name; }  
        set { this.name = value; }  
    }  
 
    public DateTime? DateOfBirth  
    {  
        get 
        {  
            return this.dateOfBirth;  
        }  
 
        set { dateOfBirth = value; }  
    }  
 
    public Person(string name, DateTime? dateOfBirth)  
    {  
        this.name = name;  
        this.dateOfBirth = dateOfBirth;  
    }  
}  
 
private void Form1_Load(object sender, EventArgs e)  
{  
        BindingList<Person> collection = new BindingList<Person>();  
        collection.Add(new Person("fred"new DateTime(1980, 1, 1)));  
        collection.Add(new Person("tom"null));  
        collection.Add(new Person("tom2"null));  
        collection.Add(new Person("tom3"null));  
        collection.Add(new Person("tom4"null));  
        collection.Add(new Person("tom5"null));  
 
        radGridView1.DataSource = collection;  
}  
 
private void button1_Click(object sender, EventArgs e)  
{  
    collection.Add(new Person("jack"new DateTime(1975, 1, 1)));  

I hope this was helpful. If you have additional questions, please contact us.

Best wishes,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Rama
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or