Click here to Skip to main content
15,908,111 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: performance problem - Array.Copy vs. Buffer.BlockCopy Pin
Luc Pattyn6-May-09 9:45
sitebuilderLuc Pattyn6-May-09 9:45 
Questionformatting of data in list box in vb 2008 Pin
sazd16-May-09 2:56
sazd16-May-09 2:56 
AnswerRe: formatting of data in list box in vb 2008 Pin
Eddy Vluggen6-May-09 3:00
professionalEddy Vluggen6-May-09 3:00 
GeneralRe: formatting of data in list box in vb 2008 Pin
sazd16-May-09 3:15
sazd16-May-09 3:15 
AnswerRe: formatting of data in list box in vb 2008 Pin
Eddy Vluggen6-May-09 3:35
professionalEddy Vluggen6-May-09 3:35 
GeneralRe: formatting of data in list box in vb 2008 Pin
sazd17-May-09 2:56
sazd17-May-09 2:56 
GeneralRe: formatting of data in list box in vb 2008 Pin
Dave Kreskowiak7-May-09 4:49
mveDave Kreskowiak7-May-09 4:49 
AnswerRe: formatting of data in list box in vb 2008 Pin
Eddy Vluggen7-May-09 10:18
professionalEddy Vluggen7-May-09 10:18 
sazd1 wrote:
so there is no option for alignment of data in columns in listbox.


It's meant as a list. If you try this;
ListBox1.MultiColumn = True
Dim i As Integer
For i = 1 To 40
    ListBox1.Items.Add("Test " & i)
Next i
You'll get a list of multiple items, stacked like this (that's assuming that your list has a height that has enough room for six items);
Test 1  Test 7  Test 13
Test 2  Test 8  Test 14
Test 3  Test 9  Test 15
Test 4  Test 10 Test 16
Test 5  Test 11 Test 17
Test 6  Test 12 Test 18


sazd1 wrote:
to add spaces is difficult.


I have made you a short example on that;
    [...]
    ListBox1.MultiColumn = False
    ListBox1.Font = New Font( _
        System.Drawing.FontFamily.GenericMonospace, _
        ListBox1.Font.Size, _
        ListBox1.Font.Style, _
        ListBox1.Font.Unit)
    Dim j As Integer
    For j = 1 To 20
        ListBox1.Items.Add(AsFixedColumnText("Test " & j, 8) & _
                           Space(3) & _
                           AsFixedColumnText(Date.Now(), 8) & _
                           Space(3) & _
                           AsFixedColumnText("Hello", 3))
    Next j

End Sub

Public Function AsFixedColumnText(ByVal text As String, ByVal length As Integer)
    If String.IsNullOrEmpty(text) Then
        Return Space(length)
    Else
        Return (text & Space(length)).Substring(0, length - 1)
    End If
End Function

This should give you an output that's formatted in columns, similar to this;
Test 1    5/7/200   He
Test 2    5/7/200   He
Test 3    5/7/200   He
Test 4    5/7/200   He
Test 5    5/7/200   He
Test 6    5/7/200   He
Test 7    5/7/200   He
Test 8    5/7/200   He
Test 9    5/7/200   He
Test 10   5/7/200   He
Test 11   5/7/200   He
Test 12   5/7/200   He
Test 13   5/7/200   He
Test 14   5/7/200   He
Test 15   5/7/200   He
Test 16   5/7/200   He
Test 17   5/7/200   He
Test 18   5/7/200   He
Test 19   5/7/200   He
Test 20   5/7/200   He

Still, I don't think that this is the ideal solution. Is there any way that you can promote the ListBox to a ListView? Or even a DataGridView?

I are troll Smile | :)

AnswerRe: formatting of data in list box in vb 2008 Pin
Henry Minute6-May-09 3:00
Henry Minute6-May-09 3:00 
QuestionDifference of two numbers Pin
Anubhava Dimri6-May-09 1:17
Anubhava Dimri6-May-09 1:17 
AnswerRe: Difference of two numbers Pin
Mycroft Holmes6-May-09 1:22
professionalMycroft Holmes6-May-09 1:22 
GeneralRe: Difference of two numbers Pin
Anubhava Dimri6-May-09 2:14
Anubhava Dimri6-May-09 2:14 
GeneralRe: Difference of two numbers Pin
Guffa6-May-09 4:25
Guffa6-May-09 4:25 
AnswerRe: Difference of two numbers Pin
Luc Pattyn6-May-09 3:52
sitebuilderLuc Pattyn6-May-09 3:52 
AnswerRe: Difference of two numbers Pin
Guffa6-May-09 4:22
Guffa6-May-09 4:22 
QuestionControl Object Created or Initialized Pin
Samir Ibrahim6-May-09 0:54
Samir Ibrahim6-May-09 0:54 
AnswerRe: Control Object Created or Initialized Pin
Mycroft Holmes6-May-09 1:21
professionalMycroft Holmes6-May-09 1:21 
QuestionVirtual Earth Bespoke Map Control Pin
Lexter33335-May-09 22:29
Lexter33335-May-09 22:29 
AnswerRe: Virtual Earth Bespoke Map Control Pin
Dave Kreskowiak6-May-09 2:19
mveDave Kreskowiak6-May-09 2:19 
QuestionProblem with API Pin
Pasan1485-May-09 21:44
Pasan1485-May-09 21:44 
AnswerRe: Problem with API Pin
Henry Minute6-May-09 6:04
Henry Minute6-May-09 6:04 
AnswerRe: Problem with API Pin
Bharat Jain6-May-09 18:51
Bharat Jain6-May-09 18:51 
QuestionVirtual Earth Map Control without using AJAX Pin
Lexter33335-May-09 20:41
Lexter33335-May-09 20:41 
AnswerRe: Virtual Earth Map Control without using AJAX Pin
Mycroft Holmes5-May-09 21:21
professionalMycroft Holmes5-May-09 21:21 
Questionmicrosoft report viewer in visual studio does not function with a stored procedure Pin
sourav_bhargava5-May-09 20:31
sourav_bhargava5-May-09 20:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.