Solved

Setting grid cell text

Posted on 1997-12-10
4
355 Views
Last Modified: 2012-05-04
What code should I use to set cell text for either a grid control or a DBgrid control, the following does not seem to work:
DbGridName.Columns(1).CellValue ("text")  nor
DbGridName.Columns(1).CellText ("text")
0
Comment
Question by:ncw
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
leeal earned 100 total points
ID: 1444634
Grid:
Grid1.text = "Data for the current cell"

DBGrid:
DBGrid1.Columns(1).Text = "Text to be displayed in the cell"
DBGrid1.Columns(1).Text = "Data to be contained in the cell"

0
 
LVL 1

Author Comment

by:ncw
ID: 1444635
Yes, got that to work with 'Grid' but an error message says "this property not available" for 'DBGrid', does it need to be the 32-bit version?
0
 
LVL 1

Expert Comment

by:leeal
ID: 1444636
umm.... not sure...
What I suggest is to make sure that you have typed (for DBGrid):
   DBGrid1.Columns(1).Text = "whatever"
instead of:
   DBGrid1.Text = "whatever"

where 'Columns' is a collection of the columns in the grid, and the number within the parenthesis is the index of the column.
- DBGrid1.Columns(0) is first column
- DBGrid1.Columns(1) is 2nd column, etc...

btw, I mistyped something in my answer for DBGrid. It should be:
DBGrid1.Columns(1).Text = "Text to be displayed in the cell"
DBGrid1.Columns(1).Value = "Data to be contained in the cell"

sorry... :p
0
 
LVL 1

Author Comment

by:ncw
ID: 1444637
Thanks for your comment. I understand your code, but for some reason the message still appears - "the object does not support this property"
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question