Изменить ширину в ListView - VB
Формулировка задачи:
подскажите как изменить ширину надписи в ListView в режиме List
Решение задачи: «Изменить ширину в ListView»
textual
Листинг программы
<font color="blue">Option</font> <font color="blue">Explicit</font> <font color="blue">Private</font> <font color="blue">Const</font> LVM_FIRST = &H1000 <font color="blue">Private</font> <font color="blue">Const</font> LVM_SETCOLUMNWIDTH = LVM_FIRST + <font color="darkblue"><b>30</b></font> <font color="blue">Private</font> <font color="blue">Declare</font> <font color="blue">Function</font> SendMessage Lib <font color="green">"user32"</font> _ Alias <font color="green">"SendMessageA"</font> _ (<font color="blue">ByVal</font> hwnd <font color="blue">As</font> <font color="blue">Long</font>, _ <font color="blue">ByVal</font> Msg <font color="blue">As</font> <font color="blue">Long</font>, _ <font color="blue">ByVal</font> wParam <font color="blue">As</font> <font color="blue">Long</font>, _ lParam <font color="blue">As</font> Any) <font color="blue">As</font> <font color="blue">Long</font> <font color="blue">Private</font> <font color="blue">Sub</font> Form_Load() <font color="blue">Dim</font> itmx <font color="blue">As</font> ListItem <font color="blue">Dim</font> lWidth <font color="blue">As</font> <font color="blue">Long</font> <font color="blue">With</font> ListView1 <font color="blue">Set</font> itmx = .ListItems.Add(, , <font color="green">"Randy"</font>) <font color="blue">Set</font> itmx = .ListItems.Add(, , <font color="green">"Jon"</font>) <font color="blue">Set</font> itmx = .ListItems.Add(, , <font color="green">"Peter"</font>) <font color="blue">Set</font> itmx = .ListItems.Add(, , <font color="green">"Matthew"</font>) <font color="blue">Set</font> itmx = .ListItems.Add(, , <font color="green">"a much longer name"</font>) <font color="blue">Set</font> itmx = .ListItems.Add(, , <font color="green">"a much much longer name"</font>) <font color="blue">Set</font> itmx = .ListItems.Add(, , <font color="green">"a really friggin much longer name"</font>) <font color="blue">Set</font> itmx = .ListItems.Add(, , <font color="green">"a really friggin much loooooonger name"</font>) <font color="blue">End</font> <font color="blue">With</font> <font color="darkblue"><i>'need this here or the lines below won't work in the Load event</i></font> <font color="blue">Me</font>.Show <font color="blue">Me</font>.Refresh <font color="darkblue"><i>' resize View -2 column to the control's width (give or take a bit)</i></font> lWidth = ListView1.<font color="blue">Width</font> + ScaleX(<font color="darkblue"><b>5</b></font>, vbMillimeters, vbPixels) SendMessage ListView1.hwnd, _ LVM_SETCOLUMNWIDTH, _ <font color="darkblue"><b>0</b></font>&, _ <font color="blue">ByVal</font> lWidth <font color="blue">End</font> <font color="blue">Sub</font>
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д