Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Activecontrol in grid & activecolumn in grid.valid
Message
From
24/09/1998 10:55:52
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00140243
Message ID:
00140372
Views:
29
>>Hi folks,
>>Is there an easier way to determine active control in grid ? This code is from beforerowcolchange and already verified it's a rowchange (nColIndex has column value) :
>
>>with this
> if !empty(.columns(nColIndex).dynamiccurrentcontrol)
> cCurrentControl = ;
> eval(.columns(nColIndex).dynamiccurrentcontrol)
> else
> cCurrentControl = .columns(nColIndex).currentcontrol
> endif
> with evaluate(".columns(nColIndex)."+cCurrentcontrol)
> .value = .value && So we can evaluate table ruleexpression
> endwith
>endwith
>
>
>>And next problem. Is there a way to determine last activecolumn in grid.valid, w/o saving it to some property ? MTIA
>>Cetin
>
>i have no answer to your question. do not understand fp well enough, but i am trying to follow along. what is dynameiccurrentcontrol vs currentcontrol? also, what do you mean by "(ncollndex has a column value)". how can you determine if ncollndex is a column or row value?
>
>thanks brenda

Hi Brenda,
Maybe exagarated a little bit adding dynamiccontrol also. A column might have many controls (default a textbox) at the same time and one is active depending dynamiccurrentcontrol expression. Currentcontrol is just initial control. Hmm lets expand it with a sample (Forget data checking, compatibility while running this example, it's just to give a feeling of Dynamiccc vs cc) :
DIMENSION aDummy[26]
FOR jx=1 to 26
  aDummy[jx] = replicate(chr(asc("A")-1+jx),10)
ENDFOR
oForm = createobject("myform")
oForm.show
READ events


DEFINE class myform as form
  PROCEDURE init
    CREATE cursor mycursor (CtrlType i, Somefield i)
    FOR ix = 1 to 20
      INSERT into mycursor ;
        (CtrlType) values (ix%4)
    ENDFOR
    GO top
    WITH this
      .height = 400
      .closable = .f.
      .addobject("grid1","mygrid")
      .addobject("myQuit1","myQuit")
      .grid1.top = .myQuit1.top + .myQuit1.height + 5
      .grid1.height = .height - (.grid1.top + 5)
      .grid1.visible = .t.
      .myQuit1.visible = .t.
      .width = .grid1.width + .grid1.left + 5
    ENDWITH
  ENDPROC

  PROCEDURE getcontrol
    LPARAMETERS lnType
    DO case
    CASE lnType = 1
      RETURN "Check1"
    CASE lnType = 2
      RETURN "Combo1"
    CASE lnType = 3
      RETURN "Options1"
    OTHERWISE
      RETURN "text1"
    ENDCASE
ENDDEFINE

DEFINE class mygrid as grid
  PROCEDURE init
    WITH this
      .recordsource = "myCursor"
      .rowheight = 50
      WITH .columns(2)
        .addobject("Check1","Checkbox")
        .Check1.caption = ""
        .Check1.visible = .t.
        .addobject("Combo1","MyCombobox")
        .Combo1.visible = .t.
        .addobject("Options1","MyOptionGroup")
        .Options1.visible = .t.
        .dynamiccurrentcontrol = "thisform.getcontrol(myCursor.ctrltype)"
        .currentcontrol = "Text1" && This is default control also
        .sparse = .f.             && Show control while column doesn't have focus
      ENDWITH
    ENDWITH
ENDDEFINE

DEFINE class MyComboBox as Combobox
  ColumnCount = (ALEN(aDummy,2))
  RowSourceType = 5
  RowSource = "aDummy"
  FirstElement = 1
  Height = 24
  NumberOfElements = (ALEN(aDummy))
  Style = 2
  Width = 100
  Name = "Combo1"
ENDDEFINE

DEFINE CLASS MyOptionGroup AS optiongroup
  AutoSize = .T.
  ButtonCount = 2
  Value = 1
  Height = 46
  Width = 77
  Name = "Optiongroup1"
  Option1.Caption = "Choice 1"
  Option1.Value = 1
  Option1.Height = 17
  Option1.Left = 5
  Option1.Top = 5
  Option1.AutoSize = .T.
  Option1.Name = "Option1"
  Option2.Caption = "choice 2"
  Option2.Height = 17
  Option2.Left = 5
  Option2.Top = 24
  Option2.AutoSize = .T.
  Option2.Name = "Option2"
ENDDEFINE

DEFINE class myquit as commandbutton
  Left=1
  Top=0
  AutoSize = .T.
  Caption="Close"
  PROCEDURE click
    Release all
    Clear events
  ENDPROC
ENDDEFINE
Now for second part, the beforerowcolchange code here was partial code from my class. Just before the code a check is done if it's a rowchange or not and this part is surrounded with a "if llChangingRow..endif". If llChangingRow (a rowchange detected) then nColIndex refers to column index.
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
Reply
Map
View

Click here to load this message in the networking platform