j'ouvre le programme, je clique sur les personnes présentes, et cela va générer
panelbutton.Width = maxwith * 5 + 7 * space panelbutton.Height = maxheight * 10 + 12 * space panelbutton.Left = Me.Width \ 2 - Me.panelbutton.Width \ 2 panelbutton.Top = Me.Height \ 2 - Me.panelbutton.Height \ 2
If (iter Mod 5 = 0) And iter <> 0 Then positionx = 6 positiony += DirectCast(ctrl, Button).Height + space End If
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionMavar = listboxname.Items.Count panelbutton.Width = maxwith * 5 + Mavar+1 * space
w = Windows.Forms.Screen.PrimaryScreen.Bounds.Width h Windows.Forms.Screen.PrimaryScreen.Bounds.height
N * Lmax +(N+1)*E < w
R * Hmax + (R+1)*E < h
"Vous êtes Romain DUPONT2".
Et les boutons qui s'ajoutent prennent comme nom l'id de la personne
For Each name As String In listname Dim mybutton As New Button With mybutton .Font = New Font("arial", 16, FontStyle.Bold) .TextAlign = ContentAlignment.MiddleCenter .Text = LTrim(Strings.Mid(name, 5)) .BackColor = Color.PowderBlue .AutoSize = False .Width = Convert.ToInt32(maxsizebuton.Width) .Height = Convert.ToInt32(maxsizebuton.Height) .Name = Strings.Left(name, 5) AddHandler .MouseClick, AddressOf mouseclickbutton End With panelbutton.Controls.Add(mybutton) Next
Imports System.Data.OleDb Module db Private Connection As New OleDb.OleDbConnection 'declares connection Public Sub Init() 'initialise le database 'à modifier pour sql server Dim base As String = "provider=microsoft.jet.oledb.4.0;data source=" & Application.StartupPath & "\DBTEST.mdb" Connection.ConnectionString = base Try Connection.Open() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Public Function GetListName() As OleDbDataReader Dim sql As String Dim recordset As OleDbDataReader recordset = Nothing sql = "SELECT Famillyname,Name,id FROM table1 ORDER BY Famillyname,Name" Dim myquery As New OleDbCommand(sql, Connection) Try recordset = myquery.ExecuteReader Catch ex As Exception MessageBox.Show(ex.Message) End Try Return recordset Connection.Close() End Function
Imports System.Data.OleDb Private Sub DesignListName() Dim myrecordset As OleDbDataReader Try myrecordset = db.GetListName ComboName.Items.Clear() While myrecordset.Read ComboName.Items.Add(myrecordset.GetString(0) & " " & myrecordset.GetString(1) & " " & myrecordset.GetString(2)) End While ComboName.Text = "liste de noms " Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
pourquoi ne pas afficher les boutons avec l'id seulement ?
Dim CmdSelectUtilisateurs As New SqlCommand("SELECT idEntite, nom + ' ' + prenom as nom_prenom FROM ENTITE", MaConnexion) 'Avec un DataAdapter on va remplir la listbox des Utilisateurs Dim dt As New DataTable() Dim daTable As New SqlDataAdapter(CmdSelectUtilisateurs) daTable.Fill(dt) lstboxUtilisateurs.DataSource = dt lstboxUtilisateurs.DisplayMember = "nom_prenom" lstboxUtilisateurs.ValueMember = "idEntite"