Solved

I want to set column header caption and data source of a DataGrid Control at run time.

Posted on 2002-04-24
7
182 Views
Last Modified: 2010-05-02
I want to know how to set the data source of a data grid control at run time.  my data source is an ADO recordset.

I try to use set DataGrid1.dataSouce=ADORec but it doesn't works. (No error)

Please give me the coding.
0
Comment
Question by:yongyih
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6967426
have you refresh the grid?

datagrid1.refresh
0
 
LVL 2

Author Comment

by:yongyih
ID: 6967524
sorry... i just found the solution.
after i add in this statement, the grid can display all the records from database.

.CursorLocation = adUseClient

Now online to delete this question.  Since you post a comment already, how about you tell me how to set the caption of the DataGrid? The column header.  Because it is follow the table fields name when display.

0
 
LVL 52

Accepted Solution

by:
Ryan Chong earned 50 total points
ID: 6967556
Try: DataGrid1.Columns(i).Caption = "Hello World"
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Expert Comment

by:stelamb
ID: 6968048
yongyih,

In the SQL you use to return the dataset redefine the headings using something like

SELECT lastname AS [Surname],
       firstname AS [Christian Name]
FROM   tblname

for example
0
 

Expert Comment

by:stelamb
ID: 6968049
yongyih,

In the SQL you use to return the dataset redefine the headings using something like

SELECT lastname AS [Surname],
       firstname AS [Christian Name]
FROM   tblname

for example
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6968087
ryancys and stelamb already gave you correct comments.

BTW stelamb, welcome to EE but take some time to read http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp. A valid comment was already posted (by ryancys). You should have post a comment.
0
 
LVL 2

Author Comment

by:yongyih
ID: 6968707
I cannot accept your comment as answer because ryancys already gave a correct answer.  But your answer is correct and very useful too. thanks.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

738 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