2009-09-02 23 views

回答

-1

您將需要爲此一個DataGrid,因爲一個列表框只顯示一個元素的每一行。但首先你需要告訴我們,你使用的是什麼UI:Winforms,WPF,ASP.NET和Silverlight。

1

如果你想顯示從2分不同的只是列數據,然後可以YOT從兩個數據合併,並添加到列表框中。

希望這個作品!

3

使用UseCustomTabOffsetsCustomTabOffsets如以下VB.NET示例所示。

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

我不完全發生了什麼事在'CustomTabOffsets'一部分,但這個工作非常漂亮的我,謝謝+1 – 2010-08-02 13:38:49

+0

列表框包裹在Windows公共控件使用列表框。當我們沒有像控件一樣的列表視圖或數據網格時,在第一個版本的Windows中使用了製表位功能。由於.NET列表框必須向後兼容,因此Microsoft將此功能添加到列表框中。 – AMissico 2010-08-02 14:12:35

+0

自定義選項卡偏移整數是所選字體的平均字符寬度的四分之一https://support.microsoft.com/zh-cn/kb/318601 – Slai 2016-07-06 13:43:33

相關問題