dgvHelper,xmlHelper,inputbox(仿vba),Evaluate(vba中函数应用于C#)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了dgvHelper,xmlHelper,inputbox(仿vba),Evaluate(vba中函数应用于C#),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3912字,纯文字阅读大概需要6分钟。
内容图文
1.在dgv中进行增加、删除、修改行时应针对dt进行操作,然后刷新xml
2.datagridview中的currentrow未必就是当前选中行
3.inputbox类
string sDescription = InputBox.ShowInputBox("请输入表达式的说明!"); publicclass InputBox : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox tbData; private System.Windows.Forms.Button btnOK; private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.ToolTip ttpShow; private System.ComponentModel.Container components = null; private InputBox() { InitializeComponent(); } protectedoverridevoid Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); } privatevoid InitializeComponent() { this.components = new System.ComponentModel.Container(); this.label1 = new System.Windows.Forms.Label(); this.tbData = new System.Windows.Forms.TextBox(); this.btnOK = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button(); this.SuspendLayout(); //// label1 //this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(13, 13); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(65, 12); this.label1.TabIndex = 0; this.label1.Text = "在此输入:"; //// tbData //this.tbData.Location = new System.Drawing.Point(84, 10); this.tbData.Name = "tbData"; this.tbData.Size = new System.Drawing.Size(471, 21); this.tbData.TabIndex = 1; //// btnOK //this.btnOK.Location = new System.Drawing.Point(146, 40); this.btnOK.Name = "btnOK"; this.btnOK.Size = new System.Drawing.Size(75, 23); this.btnOK.TabIndex = 2; this.btnOK.Text = "确定"; this.btnOK.UseVisualStyleBackColor = true; this.btnOK.Click += new System.EventHandler(this.btnOK_Click); //// btnCancel //this.btnCancel.Location = new System.Drawing.Point(373, 40); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.TabIndex = 2; this.btnCancel.Text = "取消"; this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); //// InputBox //this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(567, 75); 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); } privatevoid btnOK_Click(object sender, EventArgs e) { this.Close(); } privatevoid btnCancel_Click(object sender, EventArgs e) { this.Close(); } ///<summary>/// 显示输入框 ///</summary>///<param name="sHeadText"></param>///<param name="sHistoryText"></param>///<returns></returns>publicstaticstring ShowInputBox(string sHeadText, string sHistoryText="") { InputBox inputbox = new InputBox(); inputbox.StartPosition = FormStartPosition.CenterParent; inputbox.Text = sHeadText; if (sHistoryText!="") { inputbox.tbData.Text = sHistoryText; } inputbox.ShowDialog(); return inputbox.tbData.Text; } }
4.按excel vba中的公式evaluate计算
/// <summary> /// 利用Excel中VBA的Evaluate方法对字符串进行计算 /// </summary> /// <param name="str"></param> /// <returns></returns> public static double Cal(thisstring str) { var app = new Excel.Application(); Excel.Workbook workbook = app.Workbooks.Add(); Excel.Worksheet worksheet = workbook.Worksheets.Add() as Excel.Worksheet; var result = worksheet.Evaluate(str); app.DisplayAlerts = false; app.Quit(); double data = double.Parse(result.ToString()); return data; }
5.上项中错误返回的意义
//-2146826281 =#DIV / 0!
//-2146826246 - #N / A
//- 2146826259 =#NAME?
//-2146826288 =#NULL!
//-2146826252 =#NUM!
//-2146826265 =#REF! < -你的!
//-2146826273 = VALUE!
原文:http://www.cnblogs.com/swtool/p/7691339.html
内容总结
以上是互联网集市为您收集整理的dgvHelper,xmlHelper,inputbox(仿vba),Evaluate(vba中函数应用于C#)全部内容,希望文章能够帮你解决dgvHelper,xmlHelper,inputbox(仿vba),Evaluate(vba中函数应用于C#)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。