Hello.

I'm looking for a way to format lines on a MsgBox, so that the records don't seem out of place.

What I have is this:

http://sites.google.com/site/hqupt666/home/Untitled.jpg?attredirects=0

If you can't see it it's something like this:


Num Name HF
1 something 11
2 somethingelse 22
3 andsomethingelse 33


I've been googling and it seems there is no way of changing the MsgBox itself but how can I solve this?

Thank you.

Edited 5 Years Ago by Viperino: n/a

See if this helps.

MsgBox("Num Name HF" & vbNewLine & "1:      something(11)" & vbNewLine & "2:      somethingelse(22)" & vbNewLine & "3 andsomethingelse 33")

Also, check out this link for a custom message box.

Hello codeorder.

Thank you for your answer.

That is not what I'm looking for.

What appears in the MsgBox is the content of a Sub. This one, to be exact:

Public Sub PrintClients()
        Dim st As String = String.Format("{0,-15} {1,-15} {2,-15}", "Num", "Name", "HF")
        For Each c As Client In ClientsListBindingSource
            st &= ControlChars.CrLf & c.toString
        Next
        MsgBox(st)
    End Sub

I just want to put the results on the screen. If a MsgBox is not the best way, please make a suggestion.

Edited 5 Years Ago by Viperino: n/a

I'm looking for a way to format lines on a MsgBox, so that the records don't seem out of place. If a MsgBox is not the best way, please make a suggestion.

MessageBox simply displays a string and you can't change the font or other properties of the messabox with VB.NET.

The link that codeorder provided shows a way to do a custom "MessageBox". In your case a simpler custom "MessageBox" will do. Create a borderless form, add a ListBox control with three columns, attach ListBox's left, top and right side to borderless form and add a button at the bottom part of the form. That's the simplest way I can think of doing it.

HTH

MessageBox simply displays a string and you can't change the font or other properties of the messabox with VB.NET.

The link that codeorder provided shows a way to do a custom "MessageBox". In your case a simpler custom "MessageBox" will do. Create a borderless form, add a ListBox control with three columns, attach ListBox's left, top and right side to borderless form and add a button at the bottom part of the form. That's the simplest way I can think of doing it.

HTH

Hello Teme64. Thank you for your answer.

Ok, that will work for me. First, with that listbox solution, how can I make it to have three columns? And then, how do I put the data of the st String on them?

Sorry. I was meaning ListView not ListBox :) :

Dim TempNode As ListViewItem
Dim OneLine(2) As String

ListView1.View = View.Details
' Column headers & width
ListView1.Columns.Add("Num", 60)
ListView1.Columns.Add("Name", 60)
ListView1.Columns.Add("HF", 60)
OneLine(0) = "1"
OneLine(1) = "something"
OneLine(2) = "11"
TempNode = New ListViewItem(OneLine)
ListView1.Items.Add(TempNode)
' And so on

HTH

Ok, this does the trick of alligning the client's info. But still, I'm missing the part of reading the data. I'm saving the client's info on a csv format file. Can I just read the file to the ListView, taking out the ","?

Got it to work with this one:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim lv As New ListView()
        lv.Dock = DockStyle.Fill
        lv.View = View.Details
        lv.HeaderStyle = ColumnHeaderStyle.Nonclickable
        lv.Columns.Add("Number", 50)
        lv.Columns.Add("Name", 150)
        Me.Controls.Add(lv)
        Me.Width = 210

        Dim fileC As String = "clifile.txt"

        If File.Exists(fileC) Then
            Using sr As New StreamReader(fileC)
                While Not sr.EndOfStream
                    Dim lineText As String() = sr.ReadLine().Split(",")
                    lv.Items.Add(New ListViewItem(lineText))
                End While
            End Using
        Else
            MsgBox("File not found.")
        End If
    End Sub

    Private Sub Btn_OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_OK.Click
        MyBase.Close()
    End Sub

Sweet. Thank you for your help!

This question has already been answered. Start a new discussion instead.