LB_SETTABSTOPS does not appear to affect a CheckedListBox

妖精的绣舞 提交于 2019-12-11 06:00:10

问题


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

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()

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)

But no matter what I use for the values of tabStops, the list is formatted with standard width tab stops.


回答1:


theList.CustomTabOffsets.AddRange({40, 140, 240})
theList.UseCustomTabOffsets = True

theList.Items.Add(col1 & vbTab & col2 & vbTab & col3 & vbTab & col4)

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



来源:https://stackoverflow.com/questions/2623365/lb-settabstops-does-not-appear-to-affect-a-checkedlistbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!