how to make more than 2 column's in ListBox using C#?

前端 未结 3 741
失恋的感觉
失恋的感觉 2021-01-23 10:09

how to make more than 2 column\'s in ListBox, and how to insert data - using C# ?

thank\'s in advance

相关标签:
3条回答
  • 2021-01-23 10:32

    If you want to show just data from 2 different columns, then yot can merge data from both and add to the list box.

    Hope this works!

    0 讨论(0)
  • 2021-01-23 10:47

    You will need a datagrid for that purpose, because a listbox just displays one element each row. But first you need to tell us, what UI you are using: Winforms, WPF, ASP.NET, Silverlight.

    0 讨论(0)
  • 2021-01-23 10:52

    Use UseCustomTabOffsets and CustomTabOffsets as shown in the following VB.NET example.

    Public Class Form1
        Inherits System.Windows.Forms.Form
    
        'Form overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Me.ListBox1 = New System.Windows.Forms.ListBox
            Me.SuspendLayout()
            '
            'ListBox1
            '
            Me.ListBox1.FormattingEnabled = True
            Me.ListBox1.Location = New System.Drawing.Point(13, 13)
            Me.ListBox1.Name = "ListBox1"
            Me.ListBox1.Size = New System.Drawing.Size(248, 147)
            Me.ListBox1.TabIndex = 0
            '
            'Form1
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(292, 266)
            Me.Controls.Add(Me.ListBox1)
            Me.Name = "Form1"
            Me.Text = "Form1"
            Me.ResumeLayout(False)
    
        End Sub
        Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Me.ListBox1.UseCustomTabOffsets = True
            Me.ListBox1.CustomTabOffsets.AddRange(New Integer() {40, 40, 40})
            Me.ListBox1.Items.Add("a" + vbTab + "b" + vbTab + "c")
        End Sub
    
    End Class
    
    0 讨论(0)
提交回复
热议问题