J'ai un champ texte sur mon form. li=E9 =E0 un champ de ma=20
table de donn=E9es (binding).
Si mon champ dans ma table (ou base de donn=E9es Access) a=20
comme format "Mon=E9taire" (ex.: 25,00), comment se fait-il=20
qu'il n'affiche pas les "0" dans mon champ Texte sur mon=20
form. Il affiche "25". j'aimerais qu'il affiche ce qu'on=20
voit dans ma table de donn=E9es.
Est- ce que cela est possible, si oui comment proc=E9der?
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Alexis
J'ai trouvé et j'affiche la méthode employée pour les autres programmeurs:
Je lie mon contrôle avec le code au lieu de sa propriété
Dim b As New Binding("Text", Me.MonDataSet, "MaTable.MonChamp") AddHandler b.Format, AddressOf DecimalToCurrencyString AddHandler b.Parse, AddressOf CurrencyStringToDecimal Me.txtPrixCoutant.DataBindings.Add(b)
Les 2 fonctions appelées:
Public Sub DecimalToCurrencyString(ByVal sender As Object, ByVal cevent As ConvertEventArgs) ' The method converts only to string type. Test this using the DesiredType. If Not cevent.DesiredType Is GetType(String) Then Exit Sub End If
' Use the ToString method to format the value as currency ("c"). cevent.Value = CType(cevent.Value, Decimal).ToString("c") End Sub
Public Sub CurrencyStringToDecimal(ByVal sender As Object, ByVal cevent As ConvertEventArgs) The method converts back to decimal type only. If Not cevent.DesiredType Is GetType(Decimal) Then Exit Sub End If
' Converts the string back to decimal using the static ToDecimal method. cevent.Value = Decimal.Parse (cevent.Value.ToString, _ NumberStyles.Currency, Nothing) End Try End Sub
-----Message d'origine----- J'ai un champ texte sur mon form. lié à un champ de ma table de données (binding). Si mon champ dans ma table (ou base de données Access) a comme format "Monétaire" (ex.: 25,00), comment se fait-il qu'il n'affiche pas les "0" dans mon champ Texte sur mon form. Il affiche "25". j'aimerais qu'il affiche ce qu'on voit dans ma table de données. Est- ce que cela est possible, si oui comment procéder?
Merci de vos réponses ! .
J'ai trouvé et j'affiche la méthode employée pour les
autres programmeurs:
Je lie mon contrôle avec le code au lieu de sa propriété
Dim b As New Binding("Text",
Me.MonDataSet, "MaTable.MonChamp")
AddHandler b.Format, AddressOf DecimalToCurrencyString
AddHandler b.Parse, AddressOf CurrencyStringToDecimal
Me.txtPrixCoutant.DataBindings.Add(b)
Les 2 fonctions appelées:
Public Sub DecimalToCurrencyString(ByVal sender As Object,
ByVal cevent As ConvertEventArgs)
' The method converts only to string type. Test
this using the DesiredType.
If Not cevent.DesiredType Is GetType(String) Then
Exit Sub
End If
' Use the ToString method to format the value as
currency ("c").
cevent.Value = CType(cevent.Value,
Decimal).ToString("c")
End Sub
Public Sub CurrencyStringToDecimal(ByVal sender As
Object, ByVal cevent As ConvertEventArgs)
The method converts back to decimal type only.
If Not cevent.DesiredType Is GetType(Decimal) Then
Exit Sub
End If
' Converts the string back to decimal using the
static ToDecimal method.
cevent.Value = Decimal.Parse
(cevent.Value.ToString, _
NumberStyles.Currency, Nothing)
End Try
End Sub
-----Message d'origine-----
J'ai un champ texte sur mon form. lié à un champ de ma
table de données (binding).
Si mon champ dans ma table (ou base de données Access) a
comme format "Monétaire" (ex.: 25,00), comment se fait-il
qu'il n'affiche pas les "0" dans mon champ Texte sur mon
form. Il affiche "25". j'aimerais qu'il affiche ce qu'on
voit dans ma table de données.
Est- ce que cela est possible, si oui comment procéder?
J'ai trouvé et j'affiche la méthode employée pour les autres programmeurs:
Je lie mon contrôle avec le code au lieu de sa propriété
Dim b As New Binding("Text", Me.MonDataSet, "MaTable.MonChamp") AddHandler b.Format, AddressOf DecimalToCurrencyString AddHandler b.Parse, AddressOf CurrencyStringToDecimal Me.txtPrixCoutant.DataBindings.Add(b)
Les 2 fonctions appelées:
Public Sub DecimalToCurrencyString(ByVal sender As Object, ByVal cevent As ConvertEventArgs) ' The method converts only to string type. Test this using the DesiredType. If Not cevent.DesiredType Is GetType(String) Then Exit Sub End If
' Use the ToString method to format the value as currency ("c"). cevent.Value = CType(cevent.Value, Decimal).ToString("c") End Sub
Public Sub CurrencyStringToDecimal(ByVal sender As Object, ByVal cevent As ConvertEventArgs) The method converts back to decimal type only. If Not cevent.DesiredType Is GetType(Decimal) Then Exit Sub End If
' Converts the string back to decimal using the static ToDecimal method. cevent.Value = Decimal.Parse (cevent.Value.ToString, _ NumberStyles.Currency, Nothing) End Try End Sub
-----Message d'origine----- J'ai un champ texte sur mon form. lié à un champ de ma table de données (binding). Si mon champ dans ma table (ou base de données Access) a comme format "Monétaire" (ex.: 25,00), comment se fait-il qu'il n'affiche pas les "0" dans mon champ Texte sur mon form. Il affiche "25". j'aimerais qu'il affiche ce qu'on voit dans ma table de données. Est- ce que cela est possible, si oui comment procéder?