Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Saving changes when reordering columns in a grid in runt
Message
From
24/07/2003 04:57:11
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/07/2003 04:34:23
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00813028
Message ID:
00813030
Views:
8
>Hi all.
>
>I'am using Fox 7.
>I have a grid with approx 15 columns all with their own control source.
>My users would like to changes the columns to suit themselves each with their own preference.
>
>However if you move the columns around the order is not saved and reverts back to the original order if you exit the form and come back into it again.
>
>Thanks in advance
>Zaheed

Zaheed,
Once a grid is loaded its columns(n) always points to same column no matter how you move, size the column. You could utilize this fact to save/restore. Below is a sample doing that at runtime, you could enhnace the code to persist it per user in a table or ini file during form close and restore in form.init. For demonstration I assume you have a grid on the form named myGrid and 2 buttons for save and restore :
* First play with sizes and ordering
* then click 'Save'

* Save button click
Create Cursor temp (ColOrder i, Width i)
With Thisform.myGrid
  For ix=1 To .ColumnCount
    With .Columns(ix)
      Insert Into temp Values (.ColumnOrder,.Width)
    Endwith
  Endfor
Endwith

* Now play with size and ordering again
* then click 'Restore'

* Restore button click
Select temp
With Thisform.myGrid
  Scan
    With .Columns(Recno())
      .ColumnOrder = ColOrder
      .Width = Width
    Endwith
  Endscan
Endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform