Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on Grid

Status
Not open for further replies.

newtofoxpro

Programmer
Sep 16, 2007
301
IN
I tried my level to build GRID as under. My problem is

1) As I add HEADER as Date, Voucher No etc., I want to add FOOTER as Total for Debit, Credit, Balance at bottom side of grid.

2) Can I add picture method or clause to debit field as "@Z 999999.99"

3) Unable to locate Quit Button location, how to set Left = oForm.Width

4) Is it possible to change Color of header as well as footer

My code is..

SET CENTURY On
SET DATE dmy
CLOSE all
CREATE CURSOR xLedger (xDate d, xVouNo c(5), xDesc c(50), xDbAmt n(15,2), xCrAmt n(15,2), XBlAmt n(15,2))
INSERT INTO xLedger ( xDesc, xBlAmt) VALUES ("Opening Balance",100)
INSERT INTO xLedger (xDate,xVouNo,xDesc,xDbAmt,xCrAmt,xBlAmt) VALUES (DATE(), "00001", "Cash", 100,0,200)
INSERT INTO xLedger ( xDesc ) VALUES ("Being Cash paid")
INSERT INTO xLedger (xDate,xVouNo,xDesc,xDbAmt,xCrAmt,xBlAmt) VALUES (DATE(), "00002", "Bank", 200,0,400)
INSERT INTO xLedger (xDate,xVouNo,xDesc,xDbAmt,xCrAmt,xBlAmt) VALUES (DATE(), "00003", "Printing & Stationery",0,50,350)
INSERT INTO xLedger ( xDesc, xBlAmt) VALUES ("Closing Balance",350)
GO top

oForm=CREATEOBJECT('MyForm')
oForm.AddObject('cmdCommand1','cmdMyCmdBtn')
oForm.AddObject('oGrid','Grid')

oForm.SHOW
oForm.oGrid.Height = oForm.Height
oForm.oGrid.Width = oForm.Width-100
oForm.oGrid.DeleteMark=.F.
oForm.oGrid.ReadOnly=.T.
oForm.oGrid.SetAll("DynamicBackColor","IIF(MOD(RECNO( ), 2)=0, RGB(255,255,255),RGB(240,255,240))", "Column")
oForm.oGrid.GridLineColor=RGB(0,0,0)
oForm.oGrid.ScrollBars=2
oForm.oGrid.GridLines=2
oForm.oGrid.HighLightStyle=1
oForm.oGrid.RecordMark=.f.

oForm.oGrid.Visible = .T.
oForm.cmdCommand1.Visible =.T.
oForm.oGrid.Column1.Header1.Caption = 'Date'
oForm.oGrid.Column2.Header1.Caption = 'Voucher No'
oForm.oGrid.Column3.Header1.Caption = 'Description'
oForm.oGrid.Column4.Header1.Caption = 'Debit'
oForm.oGrid.Column5.Header1.Caption = 'Credit'
oForm.oGrid.Column6.Header1.Caption = 'Balance'

oForm.oGrid.Column1.Width = 70
oForm.oGrid.Column2.Width = 70

oForm.SHOW()
READ EVENTS

DEFINE CLASS MyForm AS Form
Closable = .F.
WindowState=2
Caption = 'Customer List'
Titlebar=1
Borderstyle=3
AutoCenter=.T.
FontName='tahoma'
FontSize=10
MaxButton=.f.
MinButton=.f.
ENDDEFINE

DEFINE CLASS cmdMyCmdBtn AS CommandButton
Caption = '\<Quit'
Cancel = .T.
Left = oForm.Width
Top = 0
Height = 25

PROCEDURE Click
CLEAR EVENTS
CLOSE ALL
ENDDEFINE
RETURN
 

1) As I add HEADER as Date, Voucher No etc., I want to add FOOTER as Total for Debit, Credit, Balance at bottom side of grid.


No. Three is no built-in footer. The best you can do is to create a row of labels or textboxes under the grid to simulate a footer.


2) Can I add picture method or clause to debit field as "@Z 999999.99"


Yes. It's not a method or a clause; it's the InputMask property of the textbox (which is in the column).


3) Unable to locate Quit Button location, how to set Left = oForm.Width


Don't understand the question. The grid doesn't have a Quit button.


4) Is it possible to change Color of header as well as footer


Yes. To change the colour of the header, just change its Backcolor (or ForeColor) property in the usual way. But see above re footers.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
What Mike said, plus:

3) Unable to locate Quit Button location, how to set Left = oForm.Width

It absolutely never makes any sense to set any control's .Left property to Form.Width. The control would be invisible, having been shoved off the form.

I think you want something like this:

button.Left = (form.width-button.width)

You also probably want to set the button to .Visible = .t. at some point.
 
No. Three is no built-in footer. The best you can do is to create a row of labels or textboxes under the grid to simulate a footer.

Ledger is a sample form where Columns are fixed. Some queries/report has more than 10 Columns and its totals. I think easy method is adding ROW for totals which scroll horizontally.

Thanks you for your valued post. Let me try.
 
@mike: I found similar stuff at download area in universalthread
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top