Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Grid Like Printing

Author  Topic 

amitkumarmadhukar
Starting Member

45 Posts

Posted - 2004-08-05 : 12:55:30
hello professional,
how days r going on

here is another problem for u guys

i am printing a Table ..... in such a manner
Printer.Print Space(10); "Items of Import:-"
Printer.FontBold = False

Printer.Print Space(10); "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Printer.Print Space(15); "Sr"; Space(5); "Description"; Space(5); "Generic"; Space(5); "Unit Price"; Space(5); "Quantity"; Space(5); "Unit of Quantity"; Space(5); "Accessories,if any"; Space(5); " Manufacter's Name"; Space(5); "Brand"; Space(5); "Model Specifications"
Printer.Print Space(10); "-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"; Space(10)


Cs.CommandText = "select Item_No,Item_Description,Generic_Description,Unit_Price,Quantity,Unit_Of_Quantity,Accessaries,Manufacter_Name,Brand,Model_Specification from Fourthbe Where Be_Id='" + BeNo + "'"
Cs.Execute

With Cs.Execute
Do While Not .EOF

Printer.Print Space(15); "" + .Fields(0) + ""; Space(5); "" + .Fields(1) + ""; Space(8); "" + .Fields(2) + ""; Space(8); "" + .Fields(3) + ""; Space(8); "" + .Fields(4) + ""; Space(8); "" + .Fields(5) + ""; Space(8); "" + .Fields(6) + ""; Space(8); "" + .Fields(7) + ""; Space(8); "" + .Fields(8) + ""; Space(8); "" + .Fields(9) + ""
Printer.Print
.MoveNext
Loop
End With

it does not print grid like structure, here the length of each fields may vary, they have sometimes full length value or some times no values

how alligned this grid


some of you suggest me left(value1+space(100),100) but sorry to say those this technique doesn't work
or i am wrong

please correct my Format String




amit kumar madhukar

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-08-05 : 14:06:43
Instead of giving us application code, could you just give us the query formatted in Query Analyzer? All testing should first be done inside Query Analyzer to make sure the data output is correct. You then pull it into your application and get it to work there.

Tara
Go to Top of Page

Pat Phelan
Posting Yak Master

187 Posts

Posted - 2004-08-05 : 16:34:18
Wow, it has been AGES since I've even thought about printing grids manually! The last time I needed to do that, formatx$ had just started to replace PRINT USING for this kind of task.

I think that your best bet using pure .NET would be to consider using a grid control, then using the form's PRINT method.

-PatP
Go to Top of Page

amitkumarmadhukar
Starting Member

45 Posts

Posted - 2004-08-06 : 04:54:44
Hello "tduggan"
the query analyzer already format the output, but i want to know how


i format my outputs in a fixed allignment while printing the output of my query.

and my query is
"select Item_No,Item_Description,Generic_Description,Unit_Price,Quantity,Unit_Of_Quantity,Accessaries,Manufacter_Name,Brand,Model_Specification from Fourthbe Where Be_Id='123456'

and want to print it in grid style printing each columns starts with left position wheather the last varible have fuller length value of not this fashion....

Item No Item Description Generic Description Unit Price
-----------------------------------------------------------------
112233 ghdghfgjhfgjhf sdgkjsfkjdfkg 125.36
1153 ghdghfgjhfgjhf sdgkjfkg 125.36
112233 ghdghfgjhfgjhf sdgkjsfkjdfkg 125.36
112233 ghdghfgjhfgjhf sdgkjsfkjdfkg 125.36
1153 ghdghfgjhfgjhf sdgkjfkg 125.36
-----------------------------------------------------------------


but currently it prints (Due to variaable length of variables)

Item No Item Description Generic Description Unit Price
-----------------------------------------------------------------
112233 ghdghfgjhfgjhf sdgkjsfkjdfkg 125.36
1153 ghdghfgjhfgjhf sdgkjfkg 125.36
33 ghdghfgjhfgjhf sdgkjsfkjdfkg 125.36
13 ghdghfgjhfgjhf sdgkjsfkjdfkg 125.36
1153454 ghdghfgjhfgjhf sdgkjfkg 125.36
-----------------------------------------------------------------

now i think u learn my question..

now can u people help me ...

can u give me the proper format string for printing....


amit kumar madhukar
Go to Top of Page

Pat Phelan
Posting Yak Master

187 Posts

Posted - 2004-08-06 : 13:42:19
You seem to be intent on doing this the hardest way you can find. Ok, I'll play along...

The first problem that you need to solve is to get consistent column formatting (basically making all columns consistent length). The easiest way to do that is to cast the varchar columns as char instead.

The next problem that you need to solve is getting a monospaced font. I'd suggest using the Windows Courier font, because it is one of the few monospaced fonts that ships on all Windows platforms.

I'm sure that you'll hit at least a few of the other priting problems that grid controls were designed to overcome. I've lived through fixing most of them, so feel free to post the next one(s) you find!

-PatP
Go to Top of Page
   

- Advertisement -