none
setting up columns in a rich text box (rtb)

    Question

  •  

    I have an application, I want to print into a rich text box and make it pretty!  I want to change size for the header and to change font of the header and then standard font for the body.  Datatable1 is a monster select statement.  It has six inner joins and two right outer joins.  It returns 78 items which will all be on this form when I am done.  This will end up being the final report to the customer and needs to look very nice.  As you can see I am trying to pad stuff and everything to make it look good, but the right column is not straight. (rtb1 is my rich text box)

     

    Mike

     

     

     

     

     

     

    Private Sub ToolStripGenerateBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles         ToolStripGenerateBtn.Click

      Dim LF As String = Chr(13)  ' I'm too lazy to write out the line feed!

      Dim CurrentFont As System.Drawing.Font = rtb1.SelectionFont

      'rtb1.Font = System.Drawing.Font("park Place")

      'rtb1.SelectionFont

      rtb1.SelectionAlignment = HorizontalAlignment.Center

      rtb1.Text = "Me Company " & LF & " me division ." & LF & " me street" & LF & " Wichita, Kansas 67214"

      'rtb1.FontStyle.Bold()

      With Me.Metaltest1DataSet.DataTable1

     

          rtb1.AppendText(LF & LF & "ULTRASONIC INSPECTION REPORT" & LF & LF)

          rtb1.SelectionAlignment = HorizontalAlignment.Left

          rtb1.AppendText(" Customer: " & PrintLeftColumn(.Rows(0).Item(13).ToString))

          rtb1.AppendText("Customer Number: " & .Rows(0).Item(62).ToString & LF) '62

          rtb1.AppendText(" Part Number: " & PrintLeftColumn(.Rows(0).Item(22).ToString))

          rtb1.AppendText("Quanity: " & .Rows(0).Item(3).ToString & LF)

          rtb1.AppendText(" Material: " & PrintLeftColumn(.Rows(0).Item(63).ToString))

          rtb1.AppendText(" Heat Treat: " & .Rows(0).Item(64).ToString & LF)

          rtb1.AppendText(" P.O. Number: " & PrintLeftColumn(.Rows(0).Item(65).ToString))

          'rtb1.AppendText("

      End With

      rtb1.Show()

    End Sub

     

     

    Private Function PrintLeftColumn(ByVal strData As String)

      Dim strReturnValue As String = ""

      strData = strData.Trim

      strData += " "

      strReturnValue = strData.PadRight(80)

     

      Return strReturnValue

    End Function

    Monday, March 24, 2008 8:03 PM

All replies

  • You could try using vbTab to separate the columns, but I'm sure there's a better control to use that already includes columns for displaying a database, like the DataGridView control.

     

     

     

    Tuesday, March 25, 2008 2:42 AM
  • I had thought about vbtab, but when I went to that help page, it was all jibberish and all the code was run together in one big word wrap blob.  totally confusing.  it must be very nice and clean.  This is what is returned to my customer's customer.  This seems so simple, i feel I need to find a high school kid to show me how!!!!   I am just totally brain locked on this.  I tried writing graphically to the bit mapped object, but when it prints out, it is very fuzzy, so I figured to make a word document (rtb) and print it out.

     

    Mike

     

     

    Thursday, March 27, 2008 8:08 PM
  • is there a way to SetTabStop with a RichTextBox control?

    or maybe a table syntax for rtf?
    Friday, March 28, 2008 12:41 AM
  • Not that I have found..

     

    What does everybody else do when they want to creat a paper from database variables????  Is RTB the answer or are people useing something better?  I had thought about useing crystal reports, but have not had luck with it.   I am pulling data from multiple tables.

     

     

    Wednesday, April 02, 2008 4:01 PM
  • We use Crystal Reports...there is also the new sql server reporting services. I could help with Crystal problems or try the Crystal Reports for Visual Studio  forum.
     
    I don't think RTF is the normal answer for creating a report.

    Wednesday, April 02, 2008 4:27 PM
  •  

    I throw back to the days of vb5 and 6, and have not had high milage with crystal reports.  I've used crystal reports when making something with the wizard and a single datatable.  Is there a way to create a structure and pass a pointer to crystal reports?? can you use pointers in vb? OH yea, as first stated, my fields are filled in from multiple tables.  I go to the work order, grab all my indexes then open each table and pull a few items based on the index, until all the data has been  gathered, then poke it in to the respective place on the form.

     

    ie.

    work order -->WorkOrderTable(w/o #) ---> indexes for table_1(index), table_2(index), ..table _n(index) --->

    MyStructure =========> CrystalReport1(&MyStructure)

    Wednesday, April 02, 2008 6:08 PM

  • Damn this "mark code block" is so hit or miss...sometimes it works other times it erases my entire post.

    anyways...

    I usually use stored procedures or join the tables in the report. You can also pass a dataset to a crystal report. When going that route you design the report using an xsd of the dataset. Then through code you build up your dataset and assign it to the report document using the SetDataSource method. Then you can use a CrystalReportViewer control to preview the report document.




    Thursday, April 03, 2008 1:39 PM
  • can you send a link to the forum you feel is better and I can continue there.  I am very new to crystal reports and anything above the basics, I am out of my water.

     

    if you want to start the string, and just post the link here.

    Friday, April 04, 2008 4:16 PM
  • Crystal Reports for Visual Studio

    http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=77&SiteID=1


    Monday, April 07, 2008 1:14 PM