Link to home
Start Free TrialLog in
Avatar of yongyih
yongyihFlag for Malaysia

asked on

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

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.
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

have you refresh the grid?

datagrid1.refresh
Avatar of yongyih

ASKER

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.

ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stelamb
stelamb

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
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
ryancys and stelamb already gave you correct comments.

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

ASKER

I cannot accept your comment as answer because ryancys already gave a correct answer.  But your answer is correct and very useful too. thanks.