Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DynamicBackColor after Column Move

Status
Not open for further replies.

JRB-Bldr

Programmer
May 17, 2001
3,281
US
I thought that I had all of my DynamicBackColor issues resolved, but now the users want to Move Columns within the Grid and problems have appeared.

Before the Columns were Moved around, everything was set to the intended background color and worked well.

Now, after Columns get Moved around, I find that my DynamicBackColor is not behaving correctly.

My DynamicBackColor expression is based on the text string of the Column's ControlSource being contained within another fixed 'control' string (or not). And, as such, I thought that it would remain accurate even after a Column Move, but apparently not.

Before the column Move, the COLUMNn was the same as the ColumnOrder That is the 'n' of the COLUMN was the same as the ColumnOrder value.

So if:

Column5.ControlSource = "Leads.DOB"
Then
Column5.ColumnOrder = 5
And, I assume
COLUMN[5].ControlSource = "Leads.DOB"

After the column Move, the COLUMNn was the no longer same as the ColumnOrder That is the 'n' of the COLUMN was NOT the same as the ColumnOrder value.

Now if:

Column5.ControlSource = "Leads.DOB"
Then
Column5.ColumnOrder = 8

And
Column8.ControlSource = "Leads.Family Count"
Then
Column8.ColumnOrder = 5

But, I do not know if
COLUMN[5].ControlSource = "Leads.DOB" && ???
COLUMN[8].ControlSource = "Leads.Family Count" && ???
Or
COLUMN[5].ControlSource = "Leads.Family Count" && ???
COLUMN[8].ControlSource = "Leads.DOB" && ???

I always assumed that the COLUMNS worked to control the 'n' of COLUMNn instead of the ColumnOrder.

Perhaps you can enlighten me if that is in-correct.

Thanks,
JRB-Bldr
 
Well, the array index of the columns member, remains constant as defined in its Init method. For example, MyForm.Grid1.Column1 is the same as MyForm.Grid1.Columns(1), unless you rename column1 to something else of course.
An easy way to check this:
?MyForm.Grid1.Column1.controlsource
?MyForm.Grid1.columns(1).controlsource

The only thing that really changes when you shift them around, is the ColumnOrder property.

Take a look at my FAQ:
How do I change grids' row/column colors/fonts, ...
faq184-3098

You can see where I loop through the columns and obtain the controlsource from there.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
What I am doing is when the user leaves the Form, the current Grid Configuration is saved off.
That Save the following information on a column-by-column basis:
ColumnName (example: "Column5")
Column_No (example: 5 for Column5)
ColumnOrder (example: 8 for Moved Column5)
ControlSrc (example: "LEADS.DOB" for Column5)
HeaderCaption (example: "DOB")
Width (example: 75)
Visible (.T./.F.)

After initally opening the Grid's ControlSource table, I build the Grid with Default settings.

At this time, while looping through the individual columns, I also build the column-specific DynamicBackColor expressions using the text string of the Column's ControlSource as mentioned above.

I next look to the GridSave file to see if settings have been stored and, if so, then I loop through the columns again re-setting the individual property values to the saved values.

I noticed that, after the Column Move, not only are the DynamicBackColors appearing on the wrong columns, but the ReadOnly (also retrieved from Saved file) are also appearing in the wrong columns.

The things that ARE working appear to be the column position and width within the Grid, the Header Caption, the Data within the columns being appropriate to the Header Caption.

Since everything works well before things are moved about, and not after (where the Restore from Saved is used) then I was assuming that my 'looping through the columns' was causing the problem but issueing the property setting to the wrong column.

Thanks,
JRB-Bldr
 
Well, in spite of not knowing EXACTLY what was causing the problem, I got around it.

When re-building the Grid off of the Saved values, instead of relying on previously established column-specific DynamicBackColor expressions, I am re-building them as well based on the Saved ColumnSource settings and things are now working.

Additionally the ReadOnly seem to be the result of the Column's (rather than the TextBox's) ReadOnly setting. Once I re-set that as well on the Re-Build from Saved, it is working.

Thanks,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top