Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Configuring my Grid
Message
From
20/06/2001 06:26:51
 
 
To
20/06/2001 05:41:45
Jimi Lee
Pop Electronic Products Ltd.
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00521308
Message ID:
00521328
Views:
17
This message has been marked as the solution to the initial question of the thread.
Hi!

Ok, catch it. I guess I will put this into the FAQ article here soon, so check often for updates.

Assume we have a grid with 2 columns based on the alias with all default controls in it and ability to alter certain events of grid (the most simple case). Look also to comments in code for designing.
* Grid.Init
&& add a property to the grid to track the highlighting row
this.AddProperty("nGridRecNo")
this.nGridRecNo = 0

this.DeleteMark = .F.
this.RecordMark = .F.
this.HighLightRow = .F.
* this.SplitBar=.F. && Set up this in design time, cannot change this in run-time.
this.ScrollBars = 3 && or 2 if all columns fit into the visible area
&& if you have no horizontal scrollbar, last grid column windth should be 1 point less than
&& required to fit last column into the visible portion of grid (1 point gap between the right
&& edge of the last column and the left edge of the scrollbar). This to avoid grid ato-scroling
&& (jumping) when cell in the last column selected

this.GridLines = 2 && vertical


setupcolumn(Grid.Column1)
setupcolumn(Grid.Column2)

* Grid AftreRowColChange event code
if this.nGridRecNo<>recno(this.RecordSource)
  this.nGridRecNo = recno(this.RecordSource)
  this.Refresh
endif

procedure SetupColumn && make it as a form or grid class method
lparameters poColumn
&& assuming default textbox is in the grid
lnColor = RGB(200,200,200) && or whatever color you want for row highlighting
with poColumn
  .Movable = .F.
  .Resizable = .F.
  .ReadOnly = .T.
  .DynamicBackColor = "iif(recno('" + .parent.RecordSource + "')=this.nGridRecNo," + ;
    allt(str(lnColor))+ "," + allt(str(.BackColor)) + ")"
  .Text1.DisabledBackColor = lnColor
  .Text1.BackColor = lnColor
  .Text1.DisabledForeColor = .Text1.ForeColor
  .Text1.ReadOnly = .T.
  .Text1.Margin = 1 && require so no jumping when selecting cell
endwith
Now, you can see the gray line under each selected cell selected row color is another than gray. It is shown watever under the grid (usually form). Put a shape (or shapes) under the grid and make its background color the same as the color of the row highlighting.

Now get rid of the text cursor. In the text box GotFocus event put SET CURSOR OFF commnad. In the TextBox LostFocus event put the Set Cursor On command.

User can select the content of the read-only cell in the grid, than do usual copy to copy it into the clipboard. You can disable textboxes to disallow this. In addition, you can change the SelectedBackColor and SelectedForeColor so selection will not be visible (double click on the control will not show the entire cell selected for copying into clipboard).

There are also some other weird things you might want to workaround. Click on the grid vertical line cause no record change (you can workaround it by writing code in certain grid events). Mouse cursor is always text and no way to change it but put the transparent shape over grid with a lot of additional functionality...

>Hi Vlad,
>
>Yeah it would be great if you can tell me in more detail.. *blush*
>
>
>
>>Hi!
>>
>>Take a look to SET CURSOR OFF command.
>>It is possible, with some effort, of course. Let me know if you require a complete list of properties and code required to set in grid to make it appear as a list.
>>
>>>Hi all,
>>>
>>>Is it possible to make my Grid acts like a listbox when I click on it to select a row? Now, a cursor will appear in the box of the grid which I clicked, but I only want the row to be selected rather than this.
>>>
>>>I have read the properties one by one but still dunno how to make it. Any help please?
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