|
-
Sep 17th, 2002, 08:31 AM
#1
Thread Starter
Frenzied Member
printing a grid control
Hey all,
I have a grid control that I populate right before I print it out... so my question is, how do I print the control with the gridlines and everything? Here's my code:
VB Code:
Printer.Print
Printer.Print "Manufacturer/Type/Size of Regulators"
optChoice(8).Value = True
GridCtrl.Row = 0
GridCtrl.Col = 0
For j = 0 To GridCtrl.Rows
For i = 0 To 4
GridCtrl.Cols = i
Printer.Print GridCtrl.Text;
Next i
Next j
I know that's probably not even close, but I'm tryin here... when I do that, it empties the contents of of the control and I get a bunch of white space when it prints out... help?!
-
Sep 17th, 2002, 08:54 AM
#2
I wonder how many charact
The code does exactly as you have instructed it to do... which is simply print the contents (the text) of each cell to the Printer.
If you want to show gridlines... things get a little more complicated.
Printer.Line (x1,y1) - (x2,y2),color
is what you need to print lines to the Printer.
You would have to develop a layout and then use
Printer.CurrentX and Printer.CurrentY to properly position the text within the lines...
But for my curiosity, why would you want the lines to print? A simple formated table with column and/or row labels will look nicer.
-
Sep 17th, 2002, 08:57 AM
#3
Thread Starter
Frenzied Member
OK, well the gridlines weren't a huge concern, but may be with some of the other tables, but I'll figure that out later.
The problem right now is that once it breaks into that second for loop, the gridctrl empties out and therefore has no more text to print. Any ideas why it might be doing this?
-
Sep 17th, 2002, 09:31 AM
#4
I wonder how many charact
I have highlighted my suspect reason why... you were using the wrong property. .Col is a different property from .Cols
VB Code:
Printer.Print
Printer.Print "Manufacturer/Type/Size of Regulators"
optChoice(8).Value = True
GridCtrl.Row = 0
GridCtrl.Col = 0
For j = 0 To GridCtrl.Rows
For i = 0 To 4
GridCtrl.[b]Col[/b] = i
Printer.Print GridCtrl.Text;
Next i
GridCtrl.[b]Row[/b]=j
Next j
-
Sep 17th, 2002, 09:55 AM
#5
Thread Starter
Frenzied Member
yay! new problem
Now it's printing out jibberish... boxes, question marks, an accented 'a'..
help... more!?
-
Sep 17th, 2002, 10:01 AM
#6
I wonder how many charact
Well, you have to give more information, how big is this datagrid control (or is it a flexgrid control?), the entire subroutine you are using to print...
You really need to check for discrepancies... In the code below,
you use j=0 to gridctrl.rows but fail to implement for i = 0 to gridctrl.Cols (unless you are purposely limiting the output to the first 5 columns .. 0,1,2,3,4)
VB Code:
Printer.Print
[b]For j = 0 To GridCtrl.Rows
For i = 0 To 4[/b]
GridCtrl.Col = i
Printer.Print GridCtrl.Text;
Next i
GridCtrl.Row=j
Next j
-
Sep 17th, 2002, 10:05 AM
#7
I wonder how many charact
Also,
Sometimes the printer driver gets messed up when fed improperly, and you have to turn off the printer for 8 seconds, reboot your computer, and turn the printer back on..
-
Sep 17th, 2002, 10:08 AM
#8
Thread Starter
Frenzied Member
Sorry, I've changed the code since posting it the first time.
The columns will always be the same regardless. The rows however will not. And this is a GridCtrl, not a FlexGrid.
VB Code:
Printer.Print
Printer.Print "Manufacturer/Type/Size of Regulators"
optChoice(8).Value = True
GridCtrl.Row = 0
GridCtrl.Col = 0
For j = 0 To GridCtrl.Rows - 1
For i = 0 To GridCtrl.Cols - 1
GridCtrl.Col = i
If i = GridCtrl.Cols - 1 Then
Printer.Print GridCtrl.Text
Else
Printer.Print GridCtrl.Text;
End If
Next i
GridCtrl.Row = j
Next j
Also, am I right by putting a semi-colon after the statement that it will not move to the next line before printing? Or is that unnecessary?
-
Sep 17th, 2002, 10:09 AM
#9
Thread Starter
Frenzied Member
Originally posted by nemaroller
Also,
Sometimes the printer driver gets messed up when fed improperly, and you have to turn off the printer for 8 seconds, reboot your computer, and turn the printer back on..
I'm printing to a network laser printer, but I guess the buffer could get screwed up, huh?
-
Sep 17th, 2002, 10:16 AM
#10
I wonder how many charact
You are correct about the semicolon thing....
As far as what control you are using, this doesn't appear to be an intrinsic control of VB, (one that comes with VB) but rather a third-party control.... one which was bought or downloaded, in which case, you will have to search the documentation for it.
I would highly suggest clearing the network printer by shutting it off... you could of course simply test that theory by trying to print a document from MS WORD, or EXCEL, or any other application....
-
Sep 17th, 2002, 10:19 AM
#11
I wonder how many charact
GridCtrl appears to be a control for eMbedded VB for pocketpcs...
-
Sep 17th, 2002, 10:20 AM
#12
Thread Starter
Frenzied Member
This is not a third party control... it came with VB 6.0 and I use it because that's what I have to use with my handheld projects and I understand it.
Also, I know there's nothing wrong with the printer, because it prints out other statements just fine. It's just the contents of the GridCtrl that it screws up.
-
Sep 17th, 2002, 10:21 AM
#13
Thread Starter
Frenzied Member
Originally posted by nemaroller
GridCtrl appears to be a control for eMbedded VB for pocketpcs...
exactly, but it's also a control for VB 6, as far as I can tell.
-
Sep 17th, 2002, 10:30 AM
#14
I wonder how many charact
Well, your code appears to be correct...
IT was printing out the datagrid content's before you came here, but with whitespace right?
-
Sep 17th, 2002, 10:36 AM
#15
Thread Starter
Frenzied Member
yes, but that's because I was basically wiping the contents of the grid before printing...
Maybe I should consider using a different Grid...
I've never used a MSFlexGrid, but I'm playing with it.
-
Sep 17th, 2002, 10:38 AM
#16
I wonder how many charact
The flexgrid shares most of the same properties with the control you are using, in fact, the control you are using was based off it.
You would probably not need to change a thing, other than change name property of the msflexgrid to gridcntrl1 or something...
-
Sep 17th, 2002, 10:50 AM
#17
Thread Starter
Frenzied Member
Yeah, I did that. Now I need to figure out how to print out the flexgrid.
:: goes to do search ::
-
Sep 17th, 2002, 12:07 PM
#18
I wonder how many charact
Use the code u were using for the datagrid...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|