dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 4, 1997

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Refer to Columns in a DBGrid Control

Columns in a DBGrid control are bound to database fields. However, the index number of a column doesn't tell you which field it represents. Therefore, referring to DBGrid1.Columns(0).Value is not very descriptive. It's better to introduce variables with clear names, which are bound to specific columns. In the declarations section of the form, for example, the code reads:
 
Dim ColOrder_ID As Column
Dim ColArticle_ID As Column
Dim ColAmount As Column
In the Form_Load event of the form, the code reads: With DBGrid1 Set ColOrder_ID = .Columns(0) Set ColArticle_ID = .Columns(1) Set ColAmount = .Columns(2) End With It's no longer necessary to refer to DBGrid1.Columns(0).Value, for example, but you can use ColOrder_ID.Value instead. ColOrder_ID is, of course, the same as DBGrid1.Columns(0). If any property value of DBGrid1.Columns(0) changes, the same property value of ColOrder_ID changes accordingly, and vice versa. Later on, when you insert a database field into the grid, you change only the index numbers of the columns in the code of the Form_Load event.
George van
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date