0
I have a problem to adjust the width with listview in VB.net, where the data loaded from the database does not adjust the width. Example: Have a database record that has a width of 250 characters and put the statement as follows:
If MTramo.Text = "Lobinho" Then
mlv1.Items.Clear()
Using con As MySqlConnection = GetConnection()
Try
con.Open()
Dim sql As String = ("SELECT Controle, Objetivo FROM objetivos WHERE Ramo LIKE 'Lobinho' AND Desenvolvimento = 'C-Carater' AND fase = 'a-Infância Média'")
Dim cmd As MySqlCommand = New MySqlCommand(sql, con)
Dim dr As MySqlDataReader
dr = cmd.ExecuteReader
'CONFIGURA O LISTVIEW
'=======================
'Permite o usuário rearranjar as colunas
mlv1.AllowColumnReorder = True
'Exibe as caixas de marcação
mlv1.CheckBoxes = True
'Seleciona um item e subitem quando a seleção e feita
mlv1.FullRowSelect = True
'Cria as colunas com os nomes do cabeçalho usando os nomes dos campos da tabela
With mlv1
.Columns.Add(dr.GetName(0), 80, HorizontalAlignment.Left)
.Columns.Add(dr.GetName(1), 435, HorizontalAlignment.Left)
End With
'Percorre a tabela e exibe todos os dados no listview
While dr.Read
Dim texto As String = CType(dr.Item(0), String)
Dim lv As New ListViewItem(texto, 0)
lv.SubItems.Add(New ListViewItem.ListViewSubItem(lv, CType(dr.Item(1), String)))
mlv1.Items.Add(lv)
End While
'Modo de visão
mlv1.View = View.Details
dr.Close()
I’m not getting to leave the "Goal" column at the required width, which would be 435. How can I do that...if anyone can help me I’m grateful.
Follow the screen to illustrate.
===Code in the View================
Private Sub mlv1_ItemChecked(sender As Object, e As ItemCheckedEventArgs) Handles mlv1.ItemChecked
For Each x As ListViewItem In Me.mlv1.Items
If x.Checked = True Then
If Me.mtxtOBJprg1.Text = Nothing And x.Text <> Me.mtxtOBJprg2.Text And x.Text <> Me.mtxtOBJprg3.Text Then 'verificar se TextBox1 esta vasia, se estiver add texto ...
Me.mtxtOBJprg1.Text = x.Text 'pegar o intem selecionado apenas o txt
Exit For
ElseIf Me.mtxtOBJprg2.Text = Nothing And x.Text <> Me.mtxtOBJprg1.Text And x.Text <> Me.mtxtOBJprg3.Text Then 'verificar se TextBox2 esta vasia, se estiver add texto ...
Me.mtxtOBJprg2.Text = x.Text 'pegar o intem selecionado apenas o txt
Exit For
ElseIf Me.mtxtOBJprg3.Text = Nothing And x.Text <> Me.mtxtOBJprg1.Text And x.Text <> Me.mtxtOBJprg2.Text Then 'verificar se TextBox3 esta vasia, se estiver add texto ...
Me.mtxtOBJprg3.Text = x.Text 'pegar o intem selecionado apenas o txt
Exit For
End If
Else
If x.Text = Me.mtxtOBJprg1.Text Then
Me.mtxtOBJprg1.Clear()
Exit For
ElseIf x.Text = Me.mtxtOBJprg2.Text Then
Me.mtxtOBJprg2.Clear()
Exit For
ElseIf x.Text = Me.mtxtOBJprg3.Text Then
Me.mtxtOBJprg3.Clear()
Exit For
End If
End If
Next x
End Sub
post HTML code from your view
– marcelogribeiro
I’m using visual basic 2015 creating a program in Vb windows form and I’m new... I don’t know how to post the html code of the view. can help me.
– Ivo Fernandes Bento
I thought it was HTML, for windows Forms I recommend you use the properties Anchor and dock
– marcelogribeiro