LB_SETTABSTOPS似乎不影响CheckedListBox [英] LB_SETTABSTOPS does not appear to affect a CheckedListBox
问题描述
我试图在WinForms应用程序的CheckedListBox中设置制表位,但是无论我做什么,它似乎都没有任何作用.我的表单代码中包含以下内容:
I am trying to set tab stops in a CheckedListBox in my WinForms application, but no matter what I do, it does not seem to have any effect. I have the following in the code for my form:
<DllImport("user32.dll")> _
Public Sub SendMessage(ByVal hWnd As IntPtr, ByVal uMsg As Int32, ByVal wParam As Int32, ByRef lParam As Int32)
End Sub
Public Const LB_SETTABSTOPS As Int32 = &H192
在表单的加载方法中,我正在执行以下操作,其中List是我的CheckedListBox:
And in the form's load method, I am doing the following, where theList is my CheckedListBox:
Dim tabStops() As Integer = {40, 140, 240}
Call SendMessage(theList.Handle, LB_SETTABSTOPS, tabStops.Length, tabStops(0))
theList.Refresh()
然后,我在循环中使用它,其中col1到col4都是列的字符串值:
And then later on, I use this in a loop, where col1 through col4 are all string values for the columns:
theList.Items.Add(col1 & vbTab & col2 & vbTab & col3 & vbTab & col4)
但是无论我用什么作为tabStops的值,列表都是使用标准宽度的制表位来格式化的.
But no matter what I use for the values of tabStops, the list is formatted with standard width tab stops.
推荐答案
theList.CustomTabOffsets.AddRange({40, 140, 240})
theList.UseCustomTabOffsets = True
theList.Items.Add(col1 & vbTab & col2 & vbTab & col3 & vbTab & col4)
这篇关于LB_SETTABSTOPS似乎不影响CheckedListBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!