Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 9th, 2004, 02:45 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Insert a Column additionally in grid

Hi,

I have created a module using flexgrid. It's column names are:
Sno Name Address

After doing this, I have programmed every part using this as standard columns. Now, i have got into a trouble of adding an extra column in the middle of Name and Address.

Eg: msflexgrid.textmatrix(i,0),msflexgrid.textmatrix(i ,1),msflexgrid.textmatrix(i,2)

Is there any possibility to avoid such circumstances afterwards. What is the correct method of adding data in grid and manipulating using that.


A.D.Ramkumar

A.D.Ramkumar
__________________
Ramkumar A D
 
Old November 9th, 2004, 03:05 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Dear Ramkumar,

The following may not be a solution to your problem. But When I had a similar situation, I did it in this way.

I created a public subroutine in a module (subFillGrid). To this routine, I pass the name of a flexgrid, a query, an array of column headings, an array of corresponding field names, database connection string. The subroutine will run the query and fill the grid in the order of columns I gave in the array. If a new column is to be inserted, I need only change the query and column array lists.

You may try this.

There are other class based solutions for this. You can create a class to handle all these types of reporting requirements. But, I am not clear about this. May be somebody else can give a smarter solution based on classes.
 
Old November 9th, 2004, 02:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Never hard code numbers is you code, use constants instead:

private const cColSno = 0
private const cColName = 1
private const cColAddress = 2

And use them like

.textmatrix(i,cColName) = "Marco"

If another column needs to be inserted, just modify the list of constants, and the code will remain unchanged.

Marco





Similar Threads
Thread Thread Starter Forum Replies Last Post
Column of a Grid Gray in Color shailesh_kumar Beginning VB 6 4 April 27th, 2007 12:59 PM
How to sort a column in data grid: kenn_rosie ASP.NET 1.0 and 1.1 Basics 1 January 26th, 2006 02:03 PM
template column in grid sureshbabu ASP.NET 2.0 Basics 1 December 14th, 2004 08:59 AM
how do i hide a column from grid alyeng2000 ASP.NET 1.x and 2.0 Application Design 3 December 29th, 2003 10:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.