Dgvhelper,xmlhelper,inputbox (VBA-like), Evaluate (VBA in functions applied to C #)

Source: Internet
Author: User

1. When adding, deleting, modifying rows in DGV, operate on the DT and then refresh the XML

The CurrentRow in 2.datagridview is not necessarily the current selected row

3.inputbox class

stringSdescription = Inputbox.showinputbox ("Please enter a description of the expression! ");  Public classInputBox:System.Windows.Forms.Form {PrivateSystem.Windows.Forms.Label Label1; PrivateSystem.Windows.Forms.TextBox Tbdata; PrivateSystem.Windows.Forms.Button Btnok; PrivateSystem.Windows.Forms.Button Btncancel; PrivateSystem.Windows.Forms.ToolTip ttpshow; PrivateSystem.ComponentModel.Container components =NULL; PrivateInputBox () {InitializeComponent (); }        protected Override voidDispose (BOOLdisposing) {            if(disposing) {if(Components! =NULL) {components.                Dispose (); }            }            Base.        Dispose (disposing); }        Private voidInitializeComponent () { This. components =NewSystem.ComponentModel.Container ();  This. Label1 =NewSystem.Windows.Forms.Label ();  This. Tbdata =NewSystem.Windows.Forms.TextBox ();  This. Btnok =NewSystem.Windows.Forms.Button ();  This. Btncancel =NewSystem.Windows.Forms.Button ();  This.            SuspendLayout (); //             //Label1//              This. Label1. AutoSize =true;  This. Label1. Location =NewSystem.Drawing.Point ( -, -);  This. Label1. Name ="Label1";  This. Label1. Size =NewSystem.Drawing.Size ( $, A);  This. Label1. TabIndex =0;  This. Label1. Text ="Enter here:"; //             //Tbdata//              This. tbdata.location =NewSystem.Drawing.Point ( -,Ten);  This. Tbdata.name ="Tbdata";  This. tbdata.size =NewSystem.Drawing.Size (471, +);  This. Tbdata.tabindex =1; //             //Btnok//              This. btnok.location =NewSystem.Drawing.Point (146, +);  This. Btnok.name ="Btnok";  This. btnok.size =NewSystem.Drawing.Size ( the, at);  This. Btnok.tabindex =2;  This. Btnok.text ="Determine";  This. Btnok.usevisualstylebackcolor =true;  This. Btnok.click + =NewSystem.EventHandler ( This. Btnok_click); //             //Btncancel//              This. btncancel.location =NewSystem.Drawing.Point (373, +);  This. Btncancel.name ="Btncancel";  This. btncancel.size =NewSystem.Drawing.Size ( the, at);  This. Btncancel.tabindex =2;  This. Btncancel.text ="Cancel";  This. Btncancel.usevisualstylebackcolor =true;  This. Btncancel.click + =NewSystem.EventHandler ( This. Btncancel_click); //             //InputBox//              This. AutoScaleBaseSize =NewSystem.Drawing.Size (6, -);  This. ClientSize =NewSystem.Drawing.Size (567, the);  This. ControlBox =false;  This. Controls.Add ( This. Btncancel);  This. Controls.Add ( This. Btnok);  This. Controls.Add ( This. Tbdata);  This. Controls.Add ( This. Label1);  This. FormBorderStyle =System.Windows.Forms.FormBorderStyle.FixedDialog;  This. Name ="InputBox";  This. Text ="InputBox";  This. ResumeLayout (false); }        Private voidBtnok_click (Objectsender, EventArgs e) {             This.        Close (); }        Private voidBtncancel_click (Objectsender, EventArgs e) {             This.        Close (); }        /// <summary>        ///Show Input Box/// </summary>        /// <param name= "Sheadtext" ></param>        /// <param name= "Shistorytext" ></param>        /// <returns></returns>         Public Static stringShowinputbox (stringSheadtext,stringshistorytext="") {InputBox InputBox=NewInputBox (); InputBox. StartPosition=formstartposition.centerparent; InputBox. Text=Sheadtext; if(shistorytext!="") {Inputbox.tbData.Text=Shistorytext; } InputBox.            ShowDialog (); returnInputbox.tbData.Text; }    }

4. Evaluate calculation by the formula in Excel VBA

    /// <summary>    ///computes a string using the Evaluate method of VBA in Excel/// </summary>    /// <param name= "str" ></param>    /// <returns></returns>     Public Static DoubleCal ( This stringstr) {      varApp =NewExcel.Application (); Excel.Workbook Workbook=app.      Workbooks.Add (); Excel.Worksheet Worksheet= Workbook. Worksheets.add () asExcel.Worksheet; varresult =worksheet.      Evaluate (str); App. DisplayAlerts=false; App.      Quit (); Doubledata =Double. Parse (result.      ToString ()); returndata; }

5. Meaning of the error return in the previous item

-2146826281 =#div/0!
-2146826246-#n/a
-2146826259 =#name?
-2146826288 =#null!
-2146826252 =#num!
-2146826265 =#ref! <-yours!
-2146826273 = value!

Dgvhelper,xmlhelper,inputbox (VBA-like), Evaluate (VBA in functions applied to C #)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.