Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2008 > C# 2008 aka C# 3.0
|
C# 2008 aka C# 3.0 Discuss the Visual C# 2008 (aka C# 3.0) language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 16th, 2008, 08:34 PM
Authorized User
 
Join Date: Apr 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello All (at 2.30 in the morning)

You see what being polite does for you? Visual C#, recognising my recent compliment, has at last given me the right form for the code line I was looking for --- which is :

testcell = (int)this.sF3DataSet.Tables["SF3"].Rows[200]["Close"];

--- and has now compiled without error !

So there you go, eh?

Now all I have to do is index the record, or sixteen of them actually, instead of just setting '200' as a constant (remembering that the index starts at 0 and not 1, yeah?) and then transfer their fields into a local array of structures (don't let me even get started on that as a mental-driving topic) instead of into a single integer, and Bob's your uncle, eh?

Right. Right. Okay. Bit of a sleep first, though, I think . . .


Cheers and regards to all,

;) Martin Woodhouse

 
Old April 17th, 2008, 09:30 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Martin,

Glad you got it worked out. I checked out your site, very interesting stuff. I like the idea of the Lightbook.

-Peter
peterlanoie.blog
 
Old October 3rd, 2008, 08:42 AM
Friend of Wrox
 
Join Date: Sep 2008
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default

I got here too late to be of help, but the cause of this problem is probably because of the difference between value types and reference types. Always remember: with reference types like a data grid, all you get is a memory address that points to where the data will be stored. That is, when you drag a data grid onto a form, in essence you are saying:

DataGridView myGrid;

This creates nothing but a 4-byte variable capable of holding a memory address that will ultimately point to the data in the grid. The current value of myGrid is null after the statement above. Your statement:

int testcell = SF3priceGrid.Rows(10).Cells(4).Value;

failed is because you are trying to make "Rows" a method call. As soon as Visual Studio saw the opening parenthesis after "Rows", it gave up because it couldn't find an object named SF3priceGrid with a method named Rows(). However, even if you had used brackets, as in:

int testcell = SF3priceGrid.Rows[10].Cells[4].Value;

that would still have failed because there are no row objects yet. The reason you got it to work is because you used data binding to actually create a data grid object in memory. Data binding has the effect of sending a memory allocation message to the Windows Memory Manager and creates a free memory block for the upcoming data. The memory address for this block is what gets assigned into myGrid, or SF3priceGrid in your example.

Dr. Purdum


Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing one cell from gridview Aker C# 1 May 22nd, 2008 03:13 PM
Merge Cell in Datagridview of visual basic 2005 Nambot VB.NET 2002/2003 Basics 1 November 12th, 2007 09:02 AM
datagridview cell validation kscase Pro Visual Basic 2005 1 July 12th, 2007 07:21 AM
Enforcing uppercase in a cell in a DataGridView cole C# 2005 2 April 24th, 2007 02:33 PM
DataGridView: Cell BackColor kesar VB How-To 0 January 8th, 2007 08:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.