Solved

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

Posted on 2002-04-24
7
175 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
  • 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 50

Accepted Solution

by:
Ryan Chong earned 50 total points
ID: 6967556
Try: DataGrid1.Columns(i).Caption = "Hello World"
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

776 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