did you use the RAD-Databind (DataSource on your winforms)? If so it might be a bit tricky.
You should load the data in a seperate layer (not in the code-behind if you can help it). Then it should be rather simple to add another row into your local data.
As you asked: here is a very simple sample.
I use same generic data:
public struct SimpleData
{
public int Id { get; set; }
public string Text { get; set; }
}
And initialize a DataGridView named GridView via:
var bindingSource = new BindingSource();
bindingSource.Add(new SimpleData {Id = 1, Text = "Hello"});
bindingSource.Add(new SimpleData {Id = 2, Text = "World"});
GridView.DataSource = bindingSource;
then you can add another row simply by
var data = GridView.DataSource as BindingSource;
data.Add(new SimpleData{Id=3, Text="!!! added"});
In a real world example I would use some well known pattern:
MVVM for Winforms
or MVP for Winforms
do seperate the View from the logic. But after all the important bit is using some kind of Bindingsource (that informs the Grid that data has changed) or reassing the changed data to the DataSource if you choose to use a shallow/simple datacontainer like List or similar.