Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid's behaviour similar to Excel list...
Message
From
28/04/2001 07:57:24
 
 
To
28/04/2001 07:20:22
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00501202
Message ID:
00501211
Views:
16
Hi, Alex!

I know the answer, but I cannot send a code because it is part of the framework. The general idea is following:

1. I have a custom header lass. In grid Init event I replace all headers for all columns by custom class. Note that new columns and grid reconstrction will also require running of this code.
2. In the header Click event I distinguish what were done by user. To do this, I have 2 properties in the header class that store grid column width and columnorder property (column position). In the Click event of the header I compare old values stored in properties with the values during the Click event of the header. When columnorder do not match, column is moved, so we have moved event. When width changed manually, we have a resized event of the column. In other case I get a mouse row and column (useing either stored values in the header.MouseDown event in the properties of header or MROW/MCOL functions), than calculate right edge position of the column in pixels. Column width changing area for column located 5 pixels around this edge (+- 5 pixels). Calculation might be complicated in general case, because it requires to account columns order, left visible column (Grid.LeftColumn), last visible column (truncated, so left edge is a left edge of the scrollable part of grid), invisible columns, deleted marks (10 points), record marks (10 points), scrollbar width (sysmetric function). If the mouse arrow is in that area, I set some flag to true. In the DoubleClick event than I check this flag, if it is set, I run the column resizing properly to the control source of the column (another complicated task). Note that Click event will run twise when Double Click, so any single clicks on the resizing area without changes for column properties should be ignored by Click event and default VFP procedure called (If you want DblClick event fire). It should also work quickly enough to fire DblClick event, so all complex algorithms (like right edge of the column) should run quickly too.
3. Column size accordingly to its control source is basen on the data width. If available, I take a field size. If not available (expresion), or it is a memo field, or it is a long character field (greater 60 characters, I don't want to display all these spaces for long character fields), I calculte copntrol source expression for rows around current record (+-10) and take its maximum width as a result. If width is less than certain value, I assign that minimum value for case values in these rows are empty. Because you will change record pointer, you require to ignore custom code of the BeforeRowColChange and AfterRowColChange for duration of th process (I used grid property as a flag for that). In addition, this should not run for cursors in 3-d buffering mode if current record contains changes, because changing record pointer will cause automatic tableupdate. IN such case I just take a current value width and calculate average with general width of field (or 80 for memo fields).

Hope this is not too complicated. Ask or contact me if you have more questions.

>Sorry,
>but you don't undestand me.
> I want on DblClick events on separator, ajust column width to Column's content automatically.
> Thanks for help.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform