Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid Problems
Message
De
11/08/2005 06:17:55
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01040115
Message ID:
01040130
Vues:
10
>I have a combo in column 2 of a grid. I set the control source to my table. How do I set a list of values from a table to be the options for the combo? Also when I click my add button I want to enter a new line in the grid. Therefore I have appended a blank record on the button click event in my table, refreshed the grid but it wont allow me to enter information even though I have the property AllowAddNew set to T.
>
>Thanks
Public oForm
oForm = Createobject('comboingrid')
oForm.Show

Define Class comboingrid As Form
  Top = 0
  Left = 0
  Height = 350
  Width = 620
  DoCreate = .T.
  Caption = "Form1"
  Name = "Form1"
  DataSession=2

  Add Object grdorditems As Grid With ;
    Height = 300, ;
    Left = 10, ;
    Top = 10, ;
    Width = 600, ;
    RecordSource = "orditems", ;
    RowHeight = 27, ;
    Name = "grdOrditems"
  Add Object cmdAdd As CommandButton With ;
    Top = 320, Left = 10, Caption = 'Add'

  Procedure Load
    Use _samples+'Data\orditems'
    Set Multilocks On
    CursorSetProp("Buffering",5,'orditems')
  Endproc

  Procedure Init
    With This.grdorditems.Column3
      .Width = 170
      .Sparse = .F.
      .AddObject('myCombo','myCombo')
      .myCombo.Visible = .T.
      .CurrentControl = 'myCombo'
    Endwith
  Endproc

  Procedure cmdAdd.Click
    Local luNewOrderID, lnLineNo
    luNewOrderID = orditems.Order_ID
    Select orditems
    Count For Order_ID = m.luNewOrderID To m.lnLineNo
    Insert Into orditems ;
      (Order_ID,line_no) ;
      values ;
      (m.luNewOrderID,m.lnLineNo+1)
    Thisform.grdorditems.SetFocus()
  Endproc
Enddefine

Define Class myCombo As ComboBox
  BoundColumn = 3
  ColumnCount = 3
  ColumnWidths = "150,150,0"
  RowSourceType = 3
  RowSource = "select prod_name,eng_name,product_id"+;
    " from products into cursor crsProducts"
  ControlSource = "Orditems.Product_id"
  Style = 2

  Procedure KeyPress
    Lparameters nKeyCode, nShiftAltCtrl
    If nKeyCode = 24 And !Eof()
      Nodefault
      Skip
    Endif
    If nKeyCode = 5 And !Bof()
      Nodefault
      Skip -1
    Endif
  Endproc
Enddefine
PS: Before harnessing a grid well do not use it for editing/adding. FoxyClasses has a class just for editing in a grid.
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform