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
Solved

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

Posted on 2002-04-24
7
178 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
String manipulation in Visual Basic 7 73
How to debug this code 7 64
Excel - Save a copy of work book 13 89
How to Add / Edit Windows Menu 4 67
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

856 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