COMO FAZER ESSAS FUNCOES PUBLICAS?

VILANOVA 20/05/2011 09:14:18
#374512
Bom dia meus amigos, aqui, eu monto um grid fazendo um loop das informacoes, gostaria de ver com voces, porque para cada grid que eu tenho eu teho que ficar montando toda essa estrutura, gostaria de ver com os amigos se tem como eu fazer uma funcao publica e apenas informar os campos para ele montar tanto o cabecalho quanto o grid por inteiro.. eu faço assim.

   
[ô]Formatação do Grid Principal
Private Sub FormataGrid()
With TDBGrid1
.Clear
WsHeader = [Ô]|Código |CNPJ/CPF ||Nome/Razão Social ||Contato |||||Valor Prod./Serv.[Ô]
WsHeader = WsHeader & [Ô]||[Ô]
.FormatString = WsHeader
.ColWidth(3) = 0: .ColWidth(5) = 0: .ColWidth(7) = 0: .ColWidth(8) = 0
.ColWidth(9) = 0: .ColWidth(10) = 0: .ColWidth(12) = 0: .ColWidth(13) = 0
.Rows = 1: .FixedRows = 1
.Cols = 14
.SelectionMode = 1
End With
End Sub
[ô]Preenche Grid Principal
Private Sub PreencherGridPrincipal()
On Error GoTo ErrorLine
Set clsCnn = New TS_AcessoBD
StrSql = [Ô][Ô] & [Ô]Select a.idpess,a.pesscodigo,a.pessnome,a.pesscontato,a.pesscnpj,a.pessestadual,[Ô]
StrSql = StrSql & [Ô]a.pesscat,a.pessdtainclusao,a.pessativo,a.pessexcluso,a.pessdtaclidesde,[Ô]
StrSql = StrSql & [Ô]a.pessvlcontrato,a.pessfantasia,a.pessfisicajuridica,b.cadnome [Ô]
StrSql = StrSql & [Ô]from cadpessoas a, cadcat b [Ô]
StrSql = StrSql & [Ô]where a.pesscat=b.id and a.pessexcluso=[ô]0[ô] [Ô]
Set MyRS = clsCnn.ExecutaSQL(StrSql)
Call FormataGrid
If MyRS.RecordCount > 0 Then
With TDBGrid1
.Redraw = flexRDNone
While Not MyRS.EOF
StrSql = [Ô][Ô] & MyRS!idpess
StrSql = StrSql & Chr(9) & MyRS!pesscodigo
StrSql = StrSql & Chr(9) & MyRS!pesscnpj
StrSql = StrSql & Chr(9) & MyRS!pessestadual
StrSql = StrSql & Chr(9) & MyRS!pessnome
StrSql = StrSql & Chr(9) & MyRS!pessfantasia
StrSql = StrSql & Chr(9) & MyRS!pesscontato
StrSql = StrSql & Chr(9) & MyRS!pesscat
StrSql = StrSql & Chr(9) & Format(MyRS!pessdtainclusao, [Ô]dd/mm/yyyy[Ô])
StrSql = StrSql & Chr(9) & MyRS!pessativo
StrSql = StrSql & Chr(9) & Format(MyRS!pessdtaclidesde, [Ô]dd/mm/yyyy[Ô]) & [Ô] [Ô] & Format(MyRS!pessdtaclidesde, [Ô]hh:mm:ss[Ô])
StrSql = StrSql & Chr(9) & Format(MyRS!pessvlcontrato, [Ô]currency[Ô])
StrSql = StrSql & Chr(9) & MyRS!pessfisicajuridica
StrSql = StrSql & Chr(9) & MyRS!cadnome

.AddItem StrSql
MyRS.MoveNext
Wend
[ô] Call ColorirGrid
.Row = 1: .Col = 0
.Redraw = flexRDBuffered
End With
Set clsCnn = Nothing
Else
TDBGrid1.Clear: TDBGrid1.Row = 0: TDBGrid1.Col = 0: Call FormataGrid
End If
Call PTextBox
Exit Sub
ErrorLine:
Call ErroSistema
End Sub



Desde ja agradeço muito a atençao
MARCELO.TREZE 20/05/2011 10:03:45
#374520
que grid vc está usando?
VILANOVA 20/05/2011 10:39:15
#374526
Amigo, msflexgrid
Tópico encerrado , respostas não são mais permitidas