How do I write in the DataGridView

T

Tony Johansson

Hello!

I have dragged a DataGridView control into a form.
I have clicked on the small square on the DataGridView where I have added
three
columns with type DataGridViewTextBoxColumn
When I run the application I can write text in the three cells in the
DataGridView.
So far so good.

When I have written new text in these three cells I click on a button
called Add Product and in this
event handler I want to read the text from these three cells because this
text should be stored in a ordinary textfile.

So can anybody give me a hint how I get the text that has been recently
added to the DataGridView.


//Tony
 
I

Ignacio Machin ( .NET/ C# MVP )

Hello!

I have dragged a DataGridView control into a form.
I have clicked on the small square on the DataGridView where I have added
three
columns with type DataGridViewTextBoxColumn
When I run the application I can write text in the three cells in the
DataGridView.
So far so good.

When I have written new text  in these three cells I click on a button
called Add Product and in this
event handler I want to read the text from these three cells because this
text should be stored in a ordinary textfile.

So can anybody give me a hint how I get the text that has been recently
added to the DataGridView.

//Tony

Hi,

Take a look at http://www.devx.com/dotnet/Article/33748
 
C

Cor Ligthert[MVP]

Tony,

As all "Data" controls, the control need a DataSource which can be binded
direct or better using a BindingSource

For the DataGridView that can be more then only a datatable, but there has
to be a datasource.

Cor
 
P

Paul

TBH Grid Views probably are not the best for Inserting data. It can be done
but think of validation etc etc. A GridView is great for paging through data
but IMHO not much good for inserting or updating data. Look up Details View
which is more apt for updating and inserting data.
 
C

Cor Ligthert[MVP]

Paul,

Be aware that the GridView is a web control, while the here used
DataGridView is a windowsform control.

Your statement can be true for web development, but does not fit for
windowsform development.
(I will do it like you in web)

Cor
 
P

Paul

LOL

Just shows what reading too quick and doing little to no windows form
development these days does for you.

It all makes sense now....Funny thing is I don't use Details View, I use my
own Custom Controls.

I always said Web development would send me mad...I need more database
development work to make me sane....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top