Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add New Line to Grid
Message
From
09/07/2007 04:04:38
 
 
To
09/07/2007 02:26:37
Aye Mya Thida Kyaw
Ingenuity Microsystems Sdn Bhd.
Kuala Lumpur, Malaysia
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01238532
Message ID:
01238540
Views:
9
This works for me:
* AddnewRecordButton.Click 

Local AddNew As Boolean
AddNew = .F.

Try
   With This.Parent   && This is an assumption, modify... 
      If Reccount(._Grid1.RecordSource) = 0
         Select (._Grid1.RecordSource)
	 Append Blank
	 AddNew = .T.
      Endif

     ._Grid1.SetFocus
     ._Grid1.ActivateCell(Reccount(._Grid1.RecordSource),2)  
      * Modify this, The ,2) may not be right for you

     If Not AddNew
        Keyboard '{DNARROW}'
	Keyboard '{ENTER}'
     Endif
   Endwith
Catch To oException
   * Do your exception handling 
   oException = Null
Endtry
HTH




>Hi Everybody,
>
>Having problem with grid....
>When user double click to make the grid-column-cell highlighted and press on the add button (which is functioning to insert a blank record in remote view), the grid will be added for two lines. When delete a line also, same problem. My coding details go as follow:
>
>*!*For Add New Line Button Click Method*!*
>SELECT fdetail
>count for not deleted() to lnline
>*!* append blank in fdetail (same problem by using this)
>INSERT INTO fdetail(line_no) values(lnline+1)
>
>*!* thisform.pageframe1.page2.grid1.refresh
>thisform.refresh
>thisform.pageframe1.page2.grid1.column1.setfocus
>
>*!*For Delete Line Button Click Method*!*
>delete in fdetail
>if !bof()
> skip -1
>endif
>
>SELECT fdetail
>lnlineno=fdetail.line_no
>go top
>do while !eof()
> replace fdetail.line_no with lnno IN fdetail
> lnno=lnno+1
> SELECT fdetail
> SKIP
>ENDDO
>if lnlineno<>0
> locate for fdetail.line_no=lnlineno
>endif
>Thisform.Refresh
>thisform.pageframe1.page2.grid1.column1.setfocus
>
>Those codes work fine for normal operations. But once user selected the grid cell by double clicking and highlighted the field, the problem encountered there.
>
>Remarks : Those codes are working in Form Class Level. The actual working form is derived from the form class.
>
>Hope to get some help on it.
>
>Thanks & much appreciates in advance,
>Mya.
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Previous
Reply
Map
View

Click here to load this message in the networking platform