Windows forms controls

ElPich Messages postés 1 Date d'inscription mardi 7 octobre 2003 Statut Membre Dernière intervention 26 octobre 2003 - 26 oct. 2003 à 12:37
huuuuu21 Messages postés 30 Date d'inscription mercredi 24 septembre 2003 Statut Membre Dernière intervention 8 septembre 2009 - 2 déc. 2003 à 09:48
1.1. Comment contrôler et formater les saisies dans un textbox : je ne veux que du numérique aussi bien relatif que non relatif et aussi bien entier que décimal avec séparateur de milliers.

1.2. Comment Personnaliser un DataGrid (Texte des entêtes de colonnes, rendre invisible certaines colonnes, etc.).

1 réponse

huuuuu21 Messages postés 30 Date d'inscription mercredi 24 septembre 2003 Statut Membre Dernière intervention 8 septembre 2009
2 déc. 2003 à 09:48
Tout d'abord bonjour, c'est la moindre des choses !!!!!!!!

j'ai fais une source, qui marche sous VB .NET, si ça merde sous vb 6.0, faudra modifier qq trucs, mais bon ca pourra t'aider pour le 1.1.

Il faut d'abord créer un form1, tu mets un textbox1 à l'intérieur, et un button1.
et ensuite tu colles la source :

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()
MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()

'Ajoutez une initialisation quelconque après l'appel InitializeComponent()

End Sub

'La méthode substituée Dispose du formulaire pour nettoyer la liste des composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Requis par le Concepteur Windows Form
Private components As System.ComponentModel.IContainer

'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Public WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(40, 40)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(216, 56)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(128, 168)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(48, 32)
Me.Button1.TabIndex = 1
Me.Button1.Text = "OK"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Public NombreTotal As Long
'J'ai déclaré un tableau à 30 unités, si on en veut plus, il faut mettre plus que 30
' Logique ! ;-p
Public TabChiffre(30) As String
Public chiffre As Integer
Public i, j As Integer
Public k As Long
Public puissance As Integer
Public NombreChiffre As Integer
Public GpeDeTrois As Integer
Public string1 As String

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'on Test si la case est vide ou non
If TextBox1.Text <> "" Then
'on test si la case est du numérique
If IsNumeric(TextBox1.Text) = True Then
i = 0
'on place le texte dans une variable
NombreTotal = Mid(TextBox1.Text, 1)
'on cherche le nombre total de chiffre
NombreChiffre = Len(TextBox1.Text)
j = NombreChiffre - 1
puissance = NombreChiffre - 1
k = 10 ^ puissance
Do Until i = NombreChiffre
' Le but est simple, il suffit de diviser chaque partie, (millier, centaine, dizaine, unité),
' et de les isoler dans un tableau.
TabChiffre(j) = Int(NombreTotal / k)
NombreTotal = NombreTotal - (TabChiffre(j) * k)
j = j - 1
i = i + 1
k = k / 10
Loop
i = 0
GpeDeTrois = 0
TextBox1.Text = ""
Do Until i = NombreChiffre
'une fois le tableau remplis, on remet en place
'le nouveau text du textbox1, en prenant garde, que
'tous les trois chiffre, il y ait une virgule.
If GpeDeTrois = 3 Then
string1 = TextBox1.Text
TextBox1.Text = "," & string1
GpeDeTrois = 0
Else
string1 = TextBox1.Text
TextBox1.Text = TabChiffre(i) & string1
GpeDeTrois = GpeDeTrois + 1
i = i + 1
End If
Loop
End If

Else
MsgBox("Inscrivez quelque chose")
End If

End Sub
End Class

MyNemIsU eh ouaih éhéhé
0
Rejoignez-nous