How do I retrieve values from a datagrid?

U

Uncle_Albert

Hi peeps,

Here's a screenshot of a particular form in my program.

http://www.jdr.dsl.pipex.com/dg1.JPG

Basically, when I click on 'Refresh Totals', I want it to retrieve all
values from the ItemPrice column, add 'em together and output the
result to the sub total text box (I've manually entered the value
already in there).

I've searched the web high and low, but it seems people are only
interested in writing to datagrids, not reading stuff from them! :?


Oh, and while I'm here, anyone know how to get the values in the data
text boxes to be just dd/mm/yyyy rather than having the time 00:00 on
the end aswell? I've tried setting the data format in Access to
dd/mm/yyyy, but no joy!

Thanks in advance peeps! 8)
 
C

Cor

Hi Uncle,

I cannot see if you use a "dataview" from that sample as datasource, if not
have a look at the
datatable compute class (and if you do look also) :))

And have for your date problems a look at
Binding.Format and Binding.Parse

It is not that difficult as it looks.

I hope this helps,

Cor
 
K

Ken Tucker [MVP]

Hi,

1) It would probably be quicker to get it from the datasource. I assume
your grid is bound to a dataset ds.

Dim dr As DataRow

Dim intTotal As Integer = 0

For Each dr In ds.Tables(0).Rows

intTotal += dr.Item("itemprice")

Next



But here is how to get a value from the datagrid

Dim strCell As String = DataGrid1.Item(1, 1).ToString


2)
http://msdn.microsoft.com/library/d...systemwindowsformsbindingclassformattopic.asp

Ken
------------------
Uncle_Albert said:
Hi peeps,

Here's a screenshot of a particular form in my program.

http://www.jdr.dsl.pipex.com/dg1.JPG

Basically, when I click on 'Refresh Totals', I want it to retrieve all
values from the ItemPrice column, add 'em together and output the
result to the sub total text box (I've manually entered the value
already in there).

I've searched the web high and low, but it seems people are only
interested in writing to datagrids, not reading stuff from them! :?


Oh, and while I'm here, anyone know how to get the values in the data
text boxes to be just dd/mm/yyyy rather than having the time 00:00 on
the end aswell? I've tried setting the data format in Access to
dd/mm/yyyy, but no joy!

Thanks in advance peeps! 8)
 

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