随笔分类 - windowForm常用的小方法
摘要:编辑器加载中View Code 1 DataAdd(year,10,getdate()):返回当前时间的10年后的年份2 3 DataAdd(month,-2,getdate()):返回当前时间的2个月前的月份4 5 datename([year、Quarter、month、day],date)6 7 功能说明:获取特定时间的年月日星期等,类型为int.
阅读全文
摘要:Xml是扩展标记语言的简写,是一种开发的文本格式。关于它的更多情况可以通过w3组织了解http://www.w3.org/TR/1998/REC-xml-19980210。如果你不知道它,那你就out太多了。.Net是如何处理Xml的?1.通过XmlDocument读写Xml文档2.通过XmlWriter和XmlReader读写Xml文档3.使用Linq to xml存取XML4.通过XmlScheme定义固定格式xml文档5.Xml序列化或者反序列化类6.通过XPath查找Xml节点7.通过Xslt转化Xml格式通过XmlDocument读写Xml文档有如下一段Xml:view source
阅读全文
摘要:View Code 1 if (table != null) 2 { 3 //panMain.Enabled = false; 4 var names = table.AsEnumerable().Select(r => r["rName"]).Distinct(); 5 foreach (var item in names) 6 { 7 this.listBAllRole.Items.Add(item.ToString()); 8 } 9 10 this.ListBSelectRole.Items.Add(txtRoles.Text.Trim());11 }这段代码
阅读全文
摘要:View Code 1 //改变字体 2 private void btnFont_Click(object sender, EventArgs e) 3 { 4 try 5 { 6 FontDialog fontDialog = new FontDialog(); 7 fontDialog.Color = dgvHistroy.RowTemplate.DefaultCellStyle.ForeColor; 8 fontDialog.Font = dgvHistroy.RowTemplate.DefaultCellStyle.Font; 9 fontDialog.AllowScriptCha
阅读全文
摘要:View Code 1 //修改栏目订单的颜色 2 private void btnfunColor_Click(object sender, EventArgs e) 3 { 4 bool isExsit = true; 5 ColorDialog fontcolor = new ColorDialog(); 6 if (fontcolor.ShowDialog() == DialogResult.OK) 7 { 8 if (!System.IO.Directory.Exists(xpath)) 9 {10 System.IO.Directory.CreateDirectory(xpat
阅读全文
摘要:View Code 1 //修改栏目订单的颜色 2 private void btnfunColor_Click(object sender, EventArgs e) 3 { 4 ColorDialog fontcolor = new ColorDialog(); 5 if (fontcolor.ShowDialog() == DialogResult.OK) 6 { 7 strColors[Convert.ToInt32(cmbFunInfo.SelectedValue)] = fontcolor.Color; 8 int argb = fontcolor.Color.ToArgb();
阅读全文
摘要:View Code 1 //绑定详细信息2 privatevoid bindfinance(DataTable dt)3 {4 dgvfinance.Columns.Clear();5 dgvfinance.Rows.Clear();6 for (int i =0; i < dt.Columns.Count; i++)7 {8 dgvfinance.Columns.Add(dt.Columns[i].ColumnName, dt.Columns[i].ColumnName);9 }10 DataGridViewRow row =null;11 for (int i =0; i <
阅读全文
摘要:在dgv的cellMouseEnter事件中View Code 1 if (e.ColumnIndex == 2 & e.RowIndex != -1)2 {3 this.Cursor = Cursors.Hand;4 }其中e.ColumnIndex就是所要指定的哪一列,对应好索引就好了!很简单的,呵呵
阅读全文
摘要:DataGridView调用的时候,想禁止列双击的时候排序,那么就要一列一列的禁止了,下面的语句能够实现:1for(inti=0;i<this.dataGridView3.Columns.Count;i++)2{3this.dataGridView3.Columns[i].SortMode=DataGridViewColumnSortMode.NotSortable;4}
阅读全文
摘要: this.comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;就可以了!
阅读全文
摘要:View Code 1 public string GetXmlNodeValue(string strXml,string strNodeName,string strValueName) 2 {powered by 25175.net 3 try 4 { 5 System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); 6 xmlDoc.LoadXml(strXml); 7 System.Xml.XmlNode xNode = xmlDoc.SelectSingleNode("//" + strNodeNa
阅读全文
摘要:View Code 1 private Image Base64ToImage(string base64String)2 {3 byte[] imageBytes = Convert.FromBase64String(base64String);4 MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);5 ms.Write(imageBytes, 0, imageBytes.Length);6 System.Drawing.Image image = System.Drawing.Image.FromStre
阅读全文
摘要:其实很简单,只是在窗体加载的时间需要两句代码就ok了小数点设为两位,增幅为0.25即numericUpDown1.DecimalPlaces = 2;numericUpDown1.Increment = 0.25M;
阅读全文
摘要:View Code 1 public partial class City : System.Web.UI.Page 2 { 3 protected void Page_Load(object sender, EventArgs e) 4 { 5 if(!IsPostBack) 6 { 7 BindProv(); 8 BindCity(); 9 }10 }11 12 //绑定市13 private void BindCity()14 {15 ddlcity.Items.Clear();16 DataTable citydt = new CitySer().GetAllCityByProvId(
阅读全文
摘要:1.View Code 1 using System.Text; 2 using System.IO; 3 4 XmlNode xmlNode1; 5 XmlDataDocument xd=new XmlDataDocument(); 6 StringBuilder xmlString1; 7 8 xmlNode1=DataSet1;//DataSet1为返回的数据集 9 if(xmlNode1==null) //--存储过程执行失败10 return;11 xmlString1=new StringBuilder(xmlNode1.OuterXml);12 if(xmlString1.ToS
阅读全文
摘要:C#中改变dgv中的字体很简单的,只需要一个简单的方法,就OK了View Code 1 //改变字体 2 private void btnFont_Click(object sender, EventArgs e) 3 { 4 try 5 { 6 FontDialog fontDialog = new FontDialog(); 7 fontDialog.Color = dgvHistroy.RowTemplate.DefaultCellStyle.ForeColor; 8 fontDialog.Font = dgvHistroy.RowTemplate.DefaultCellStyle.Fo
阅读全文
摘要:View Code 1 privatestaticint nciisMoidyOffFinance(IP_OrderDrivingLicence model_orders, int typeId)2 {3 //查询消费时,保存记录编号4 int OrderId =0;5 using (SqlConnection connection =new SqlConnection(SqlHelper.connectionString))6 {7 connection.Open();8 //使用当前的SQL连接 创建事务并添加共享锁9 SqlTransaction tran = connection.Be
阅读全文