msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Printing a MSFlexgrid by Printform method

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
Majeed



Joined: 07 Dec 2007
Posts: 1

PostPosted: Fri Dec 07, 2007 3:27 pm    Post subject: Printing a MSFlexgrid by Printform method Reply with quote

Hello
I want to print a MS Flexgrid by the printform method (VB6) but the grid is
long. I want to be able to scroll the grid down from the command button (not
manually) to row number 50 for example and print from row 50 to row 65
Can you help???
Thank you

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
Ken Halter



Joined: 04 Oct 2007
Posts: 4150

PostPosted: Fri Dec 07, 2007 12:12 pm    Post subject: Re: Printing a MSFlexgrid by Printform method Reply with quote

"Majeed" wrote in message @uwe...
> Hello
> I want to print a MS Flexgrid by the printform method (VB6) but the grid
> is
> long. I want to be able to scroll the grid down from the command button
> (not
> manually) to row number 50 for example and print from row 50 to row 65
> Can you help???
> Thank you

PrintForm, obviously, is there to give you a hard-copy of the "on screen"
version of your form. There's nothing built in to help with oversized forms
or scrolling controls to see their contents.

Using the class below, you can print the contents of the grid, but it won't
show the rest of your controls.... all that can be "fixed" by adding more
code. (all anything takes is more code )

A (Flex)Grid printing class, version 2
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=10312&lngWId=1


--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm
Back to top
View user's profile Send private message
Ken Halter



Joined: 04 Oct 2007
Posts: 4150

PostPosted: Fri Dec 07, 2007 12:18 pm    Post subject: Re: Printing a MSFlexgrid by Printform method Reply with quote

"Majeed" wrote in message @uwe...
> Hello
> I want to print a MS Flexgrid by the printform method (VB6) but the grid
> is
> long. I want to be able to scroll the grid down from the command button
> (not
> manually) to row number 50 for example and print from row 50 to row 65
> Can you help???
> Thank you

oops... missed that 50-65 part

Just experiment with the flexgrid's TopRow property. That's how you can
control which rows are showing.


--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm
Back to top
View user's profile Send private message
glorious18 via VBMonster.



Joined: 07 Dec 2007
Posts: 1

PostPosted: Fri Dec 07, 2007 10:53 pm    Post subject: Re: Printing a MSFlexgrid by Printform method Reply with quote

Hello Ken

This class won't work with me since it converts the grid to a picture that
can be printed. I want to be able to print a colored full table. How???

Ken Halter wrote:
>> Hello
>> I want to print a MS Flexgrid by the printform method (VB6) but the grid
>[quoted text clipped - 4 lines]
>> Can you help???
>> Thank you
>
>oops... missed that 50-65 part
>
>Just experiment with the flexgrid's TopRow property. That's how you can
>control which rows are showing.
>

--
Message posted via VBMonster.com
http://www.vbmonster.com/Uwe/Forums.aspx/vb-syntax/200712/1
Back to top
View user's profile Send private message
Ken Halter



Joined: 04 Oct 2007
Posts: 4150

PostPosted: Fri Dec 07, 2007 5:21 pm    Post subject: Re: Printing a MSFlexgrid by Printform method Reply with quote

"glorious18 via VBMonster.com" wrote in message @uwe...
> Hello Ken
>
> This class won't work with me since it converts the grid to a picture that
> can be printed. I want to be able to print a colored full table. How???

If the PrintForm method was giving you color, continue to use that... I've
never had a color printer hooked up for tests, so I have no idea what the
results will be like.... Use the grid's TopRow property to scroll to the
first row you want to print.

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm
Back to top
View user's profile Send private message
Steve Rowell



Joined: 13 Dec 2007
Posts: 2

PostPosted: Thu Dec 13, 2007 4:13 am    Post subject: Re: Printing a MSFlexgrid by Printform method Reply with quote

Hi Majeed,

A very simplified version of what I like to do with printing grids.
Example for a VB6 ListView control.

in a Report.bas module:

Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hWnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Public Function CreateReport(ByVal hWnd As Long, _
ByVal Optional sOperation As
String = "Print", _
sErrorMessage As String) As
Boolean
On Error GoTo EH

Dim bFileClosed As Boolean
Dim xItm As ListItem
Dim xSubItem As ListSubItem
Dim ff As Long
Dim sHtml as String
Const REPORT_PATH As String = "c:\myReport.html"

sHtml = "My Report " content=" & Chr$(34) & "text/html; charset=iso-8859-1" &
_
Chr$(34) & ">" & vbCrLf

sHtml = sHtml & "" & vbCrLf

For Each xItm In lvwGrid.ListItems
sHtml = sHtml & " " & vbCrLf
sHtml = sHtml & " " & xItm & "" & vbCrLf
For Each xSubItem In xItm.ListSubItems
sHtml = sHtml & " " & xSubItem & "" & vbCrLf
Next
sHtml = sHtml & " " & vbCrLf
Next
sHtml = sHtml & ""

ff = FreeFile
Open REPORT_PATH For Output As #ff
Print #ff, sHtml
Close #ff
bFileClosed = True

ShellExecute hWnd, sOperation, REPORT_PATH, vbNullString, vbNullString,
1
CreateReport = True

CleanUp:
On Error Resume Next
If Not bFileClosed Then
Close #ff
End If
Exit Function

EH:
sErrorMessage = Err.Description
Resume CleanUp
End Function

Call it from a Form module using something like this.

Private Sub Command1_Click()
Dim sErrorMessage As String
If Not CreateReport(Me.hWnd, ,sErrorMessage) Then
MsgBox sErrorMessage
End If
End Sub

Haven't checked this with VB6, just typed it in, but it should give you a
rough idea...

hth,
Steve

"Majeed" wrote in message @uwe...
> Hello
> I want to print a MS Flexgrid by the printform method (VB6) but the grid
> is
> long. I want to be able to scroll the grid down from the command button
> (not
> manually) to row number 50 for example and print from row 50 to row 65
> Can you help???
> Thank you
>

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group