How to change the content change in DataGrid and the different databases? For example: Database is 1 and 0, and a column in Data

xiaoxiao2021-03-06  41

This thing is not difficult, but everyone will think of making an article in the SQL statement, but feel uncomfortable, the solution to the solution is to use binding.format events and binding.parse events but in my watch "ADO.NET technology insider "I don't know if I can solve this.

The following example creates a binding, adding a ConvertEventHandler to the Parse event and Format event, and add binding to the TEXTBOX control through the DataBindings property. DecimaltocurrencyString events added to the Format event delegate to format the binding value into currency using the toString method. The CurrencyStringTodecimal event added to the PARSE event is entrustted to turn the value displayed by the control to the Decimal type.

private void DecimalToCurrencyString (object sender, ConvertEventArgs cevent) {// The method converts only to string type Test this using the DesiredType if return.. (cevent.DesiredType = typeof (string)!);

// Use the toString method to format the value as currency ("c"). Cevent.value = (DECIMAL) CEVENT.VALUE) .tostring ("c");}

Private Void CurrenCystringTodEcimal (Object Sender, ConvertEventArgs Cevent) {// The Method Converts Back to Decimal Type Only (CEVENT.DesiredType! = TypeOf (Decimal)

// Converts The String Back to Decimal Using The Static Parse Method. Cevent.Value = Decimal.Pars (Cevent.Value.toString (), NumBerstyles.currency, null;}

private void BindControl () {// Creates the binding first The OrderAmount is typed as Decimal Binding b = new Binding ( "Text", ds, "customers.custToOrders.OrderAmount");.. // Add the delegates to the event. B.FORMAT = New ConvertEventHandler (decimaltocurrencystring); b.Parse = new converteventHandler (currencyStringTodecimal); Text1.Database.add (b);}

转载请注明原文地址:https://www.9cbs.com/read-71864.html

New Post(0)