Tyke Posted February 4, 2012 Posted February 4, 2012 Is it possible to send all of the data displayed in a listbox, even when you have to scroll down to see it all, directly to the system printer? Quote
BlackBox Posted February 4, 2012 Posted February 4, 2012 I'm not sure what the ListBox data is, but if you're wanting to print the data, I presume that the items in the data list represent drawing (or file) names? In which case, you can use a Sub that uses a List, or Dictionary as an argument, then iterate the argument items (If System.IO.File(item).Exists = True Then...) to send the items to the system printer, no? Quote
fixo Posted February 5, 2012 Posted February 5, 2012 You can't do it directly There are 2 ways Easiest one is to push the data in .csv file then print out from there The hard way is to write your own ListBoxPrinting class, something like just for DatagridView I saw on codeproject.com Quote
Tyke Posted February 6, 2012 Author Posted February 6, 2012 (edited) I'm not sure what the ListBox data is, but if you're wanting to print the data, I presume that the items in the data list represent drawing (or file) names? In which case, you can use a Sub that uses a List, or Dictionary as an argument, then iterate the argument items (If System.IO.File(item).Exists = True Then...) to send the items to the system printer, no? The data in the ListBox is all the XData on various objects exported from a GIS system that need to be easily read from the user. The descriptions and keys of the data are a bit cryptic and the program displays a logical description together with its associated value (e.g. Installation Date: 26 October 2001, or Manufacturer: Big Fish Industries)). For some objects there have more than 60 pieces of XData and it would be useful for the user to click a button and get an instant print out the XData. I already have a button to save the data to a file, but sometimes that's a big hammer for this small nut. fixo - as I said to RenderMan an option for saving the data to an ascii file is already there and it would be simple enough to print it out from there, but it takes too long and I need to do it by a single click of a button. I have a workaround that seems to work, I'm testing it at the moment. That is to have a form which is not displayed to the user and to have just a single ListBox on the form, with no other controls whatsoever. The data is written in the background to the ListBoxwhen the object is queried and its XData displayed on screen, if the user then hits the print button I use the Form.PrintForm method to instantly print the data to the current system printer. After playing around with the size of the ListBox on the non displayed form I now get an A4 sheet with a nice border which can display 80 lines of text before going into scroll mode and as we will never get to the 80 lines of data I think I can live with the result. It was so much easier when we worked in DOS and didn't have network printers. I'll have to look for that ListBoxPrinting class, thanks for the tip. Edited February 6, 2012 by Tyke typo Quote
Jeff H Posted February 6, 2012 Posted February 6, 2012 You could also use a PrintDocument object. Inside the PrintPage event use e.Graphics.DrawString version that takes a RectangleF for the bounding box. Quote
Tyke Posted February 7, 2012 Author Posted February 7, 2012 You could also use a PrintDocument object. Inside the PrintPage event use e.Graphics.DrawString version that takes a RectangleF for the bounding box. Thanks for the info Jeff. I'm working here in VBA and I'm not too sure if this would work. But if we land the job it could well be worth porting the VBA to .NET and then this would work well. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.