Then the settings of the PrintDialog are assigned to the PrinterSettings-Property of the printForm1-component. To print the form, first a PrintDialog is shown allowing the user to select a printer. Now let’s step to the EventHandler of the “Print Form!”-Button. But before that, go to the designer and drag’n’drop a PrintForm-component out of the Toolbox on the Form.Īfter dropping the PrintForm-component, you’ll find it in the Component Tray of the Windows Forms-Designer. ![]() The eventhandler of that Button is currently empty. The Form above already contains a “Print Form!”-Button. PictureBox1.Image = Image.FromFile(dlg.FileName) ![]() private void btnBrowse_Click(object sender, EventArgs e)įilter = "JPEG (*.jpg)|*.jpg|JPEG (*.jpeg)|*.jpeg" The Browse-Button does nothing more than showing an OpenFileDialog and setting the Text-Property of the TextBox to the selected file and assigning the chosen image to the Image-Property of the PictureBox. The application just has a Browse-Button to browse an image from the filesystem, a PictureBox to display the image and a TextBox displaying the path to the image. Let’s take a look at a small sample by using a very simple Windows Forms application. Simply drop this component on your form, and you’ll find all the functionality you need. ![]() In this Tab, you’ll find a component called PrintForm. When you design your WinForms-Application you’ll find a Tab Visual Basic PowerPacks in the Toolbox of Visual Studio 2008. Did you ever wanted to print a Form without calling any native code? Well, with Windows Forms and Visual Studio 2008 this is a really simple exercise.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |