摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace GoldCubePos.App{ public partial class Form1 : Form { public Form1() { InitializeComponent(); ToolStripControlHost
阅读全文
摘要:方法一:Uri uri = new Uri("http://www.163.com");this.webBrowser1.Url = uri;方法二:System.Diagnostics.Process.Start("http://www.163.com");
阅读全文
摘要:#region 导出Excel /// <summary> /// 导出Excel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOutExcel_Click(object sender, EventArgs e) { try { foreach (System.Diagnostics.Process thisproc in System.Di
阅读全文
摘要:DataView view = new DataView();view.Table = DataTableA;view.RowFilter = "itemType = 'book'";//itemType是DataTableA中的一个字段DataTableB= view.ToTable();或者:DataRow[] rows = DataTableA.Select("itemType = 'book'");DataTableB= DataTableA.Clone();foreach (DataRow row in rows
阅读全文
摘要:/// <summary> /// 给DataTable添加新的行和列 /// </summary> public void DataTableChangeDt() { //---------********动态给DataTable添加数据*********--------- newtb = new System.Data.DataTable(); DataColumn column = new DataColumn("column1", typeof(string));//新增列 newtb = dt; newtb.Columns.Add(colu
阅读全文
摘要:/// <summary> /// 获取DataGrid的列名 /// </summary> /// <param name="dt"></param> /// <returns></returns> protected string[] getDTCol(System.Data.DataTable dt) { string cols = string.Empty; for (int i = 0; i < dt.Columns.Count; i++) { cols += (dt.Columns[i
阅读全文
摘要:List<string> num = new List<string>(); try { for (int i = 0; i < DataGrid1.Rows.Count - 1; i++) { double aa = 0; for (int j = 1; j < DataGrid1.Columns.Count; j++) { double bb = Convert.ToDouble(DataGrid1.Rows[i].Cells[j].Value); aa += bb; } num.Add(aa.ToString()); } } catch (Except
阅读全文
摘要://**************************************//////////////////////////////// #region 显示统计列 /// <summary> /// 显示DataGridView的统计信息 /// </summary> /// <param name="dgv"></param> /// <param name="SummaryColumns">要统计的列名称或数据源绑定列名称</param> public void Sho
阅读全文
摘要:Dictionary<string, string>是一个泛型 他本身有集合的功能有时候可以把它看成数组 他的结构是这样的:Dictionary<[key], [value]> 他的特点是存入对象是需要与[key]值一一对应的存入该泛型 通过某一个一定的[key]去找到对应的值 举个例子: //实例化对象 Dictionary<int, string> dic = new Dictionary<int, string>(); //对象打点添加 dic.Add(1, "one"); dic.Add(2, "two&qu
阅读全文
摘要:①DataGridView中的Columns属性里面可以设置。进入“EditColumns”窗口后,在相应的列属性设置里面把SortMode属性选择为"NotSortable"② for (int i = 0; i < this.dataGridView1.Columns.Count;i++) { this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; }
阅读全文
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Globalization;//////引用内置namespace WindowsFormsApplication1{ public partial class Form3 : Form { #region private
阅读全文
摘要:话说有了WebBrowser类,终于不用自己手动封装SHDocVw的AxWebBrowser这个ActiveX控件了。这个类如果仅仅作为一个和IE一模一样浏览器,那就太没意思了(还不如直接用IE呢)。那么,无论我们是想做一个“定制版IE”,还是希望利用HTML来做用户界面(指WinApp而非WebApp。许多单机软件,包括Windows的帮助支持中心,都是HTML做的),都少不了Windows Form和包含在WebBrowser中的Web页面的交互。本文将通过几个实际的例子,初步介绍一下WinForm和WebBrowser所包含的Web页面之间的交互。下面的代码假设你已经建立了一个Windo
阅读全文
摘要:1)、C#中重写窗口过程不用再调用SetWindowLong API了,直接overide一个WndProc就可以了。 2)、Windows API中的HDC可以通过Graphics.FromHdc()转换为(创建出)System.Drawing.Graphics,然后就可以用.NET Framework (GID+??)提供的绘图功能方便地进行画图了。终于可以抛开讨厌的GDI API了(说实在话,在C#中调用Windows API真的太麻烦了:)。代码如下:using System;using System.Drawing;using System.Drawing.Drawing2D;us.
阅读全文
摘要:第一:JS代码<script language=”javascript”>function ShopXG(infor){alert(‘我要开网店、携购独立网店系统,模板最全,最专业的系统!’);return;}</script>C#代码调用如下: using System.Security.Permissions; 注意: 类定义前需要加上下面两行,否则调用失败! [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] [System.Runtime.InteropServices.Com
阅读全文
摘要:建立一个WinForm应用程序 添加MenuStrip控件,填写两个功能“读取” 和“导出数据”。 用了两个DataSet控件和对话框“打开(OpenFilesDialog控件)"和"保存(SaveFilesDialog控件)"读取private void 读取ToolStripMenuItem_Click(object sender, EventArgs e){ if (opFileDlg .ShowDialog() == DialogResult.OK) { if(opFileDlg .OpenFile()!=null) { twoXML .ReadXml (
阅读全文
摘要:注,使用时需要先判断this.dataGridView1.SelectedCells.count,不为0 在进行上面的操作。获取总行数:dataGridView1.Rows.Count;获取当前选中行索引:int i = this.dataGridView1.CurrentRow.Index;获取当前选中列索引:int j = this.dataGridView1.CurrentCell.ColumnIndex;方法一:this.dgvStuList.SelectedRows[0].Cells["列"].Value.ToString()方法二:dgvStuList.Rows
阅读全文
摘要:public class WinformStyle { #region 定制窗体样式 /// <summary> /// 定制窗体(Lable{背景:天蓝色},TextBox{文本为空},ComboBox{文本不可编辑},DateTimePicker{大小:190,31}) /// </summary> /// <param name="parentControl">父级容器</param> /// <param name="frmFont">字体大小</param> public
阅读全文
摘要:方法一:private void tBox_KeyPress(object sender, KeyPressEventArgs e){ if (e.KeyChar == 0x20) e.KeyChar = (char)0; //禁止空格键 if ((e.KeyChar == 0x2D) && (((TextBox)sender).Text.Length == 0)) return; //处理负数 if (e.KeyChar > 0x20) { try { double.Parse(((TextBox)sender).Text + e.KeyChar.ToString())
阅读全文
摘要:this.ActiveControl = txtStuName;
阅读全文