Tag = TxtBox 'save a reference to the textbox for use during printing Size = TxtBox.Size 'size it to the textbox boundaries Location = TxtBox.Location 'locate the PictureBox to the provided TextBox control Private Sub JustifyTextBox(ByRef TxtBox As TextBox)ĭim picImage As PictureBox = New PictureBox 'create a PictureBox object (The textBox data will be painted to this) ' be able to access them through the user itnerface. ' Also, there is no need to render them ReadOnly, because the user will not ' NOTE: You can duplicate the above code for as many text boxes as you require. ' 'This will also link the created PictureBox's Paint() event to JustifyText_Paint ' JustifyTextBox(TextBoxObjectToJustify) 'create a PictureBox control to justify the text, and hide this TextBox ' Set up your code to use the JustifyTextBox() method and the JustifyText_Paint() event like this: ![]() ' : typeface, size, and enhancements will not display in the PictureBox. ' : data from its Text property, so pretty text and coloring and font ' : the TextBox casting to a RichTextBox, it would only process the ' : render everything else, otherwise, if you were to simply replace ' : you really should consider interpreting the RTF code to properly By the way, though you can do this with a RichTextBox, ' : Having written many dozens of printer drivers over the years, this ' : as a printer driver will process spacing for justification. ' Purpose : Reformat spacing in a textbox to allow for variable spacing, exactly ' Copyright (c) David Ross GOben March 10, 2013. It is not tied to one object (that would defeat the object oriented pardigm, manyway). You can apply this to as many TextBoxes as you require. It takes care of all PictureBox object creation and painting chore. ![]() Then invoke the JustifyTextBox() method by providing it with your TextBox, such as JustifyTextBox(Me.MyTextBox), and you are off to the rwaces. To use this code, which consists of a JustifyTextBox() method and a JustifyText_Paint() event, sinply place the desired TextBox and format it where you want it. Although I am an Assembler and C/C++ developer, I have fallen in love with VB.NET and have written it in VB (I can write in tweo hours what used to take me two weeks in C++). Maybe they can reformat it, or if they ask, I will send them the straight code. I will provide the code to do this below, though I am not sure how well it will render on this web page. Being a vetran of many dozens of printer drivers, this is old hat to me. One needs to replace the spaces with special codes to indicate the pixel width for the spacing. However, if you are like me and just want to display textbox data justified, such as in an About Box or some other dialog, this is doable by using a PictureBox and rendering it to it while keeping the actual textbox hidden. ![]() This is a slippery slope, and as already indicated, a custom control is really needed.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |