Remove the DataBinding information in WinForm with C # and attached to DATAROW

xiaoxiao2021-03-06  73

private void button1_Click (object sender, System.EventArgs e) {try {object ds; string bindingField, propertyName; System.Data.DataRow dr = objdataSet.Tables [0] .NewRow (); foreach (Control cl in this.Controls) {foreach (System.Windows.Forms.Binding bd in cl.DataBindings) {bindingField = bd.BindingMemberInfo.BindingField; ds = bd.DataSource; propertyName = bd.PropertyName; Type myType = cl.GetType (); // Get the PropertyInfo object by passing the property name PropertyInfo myPropInfo = myType.GetProperty (propertyName);.. // Display the property name Console.WriteLine ( "The {0} property exists in MyClass.", myPropInfo.GetValue (cl, null)) DR [bindingfield] = mypropinfo.getValue (cl, null); //cl.database.remove (BD);}} Objdataset.Tables [0]. Rows.Add (DR);} catch (Exception Err) {Console .Writeline ("{0} Exception Caught.", Err.MESSAGE);

}

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

New Post(0)