自定义属性的应用

新建解决方案WindowsFormsApplication1 新建类MyAttribute using System; namespace WindowsFormsApplication1{ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] [AttributeUsage(AttributeTargets.Class, AllowMultiple = t...
组件 | 2008-06-02 14:09 | 阅读 3840 次 | 评论 0 条

编程中常用的SQL

1、查询某一表的主键 sp_pkeys tabelname 2、查询数据库中的所有表的名称 select [name] from sysobjects where xtype = 'U' and [name] <> 'sysdiagrams' and category=0 order by [name] 3、查询指定表的列名,类型,长度 select syscolumns.name AS ColumnName,systypes.name AS TypeName,syscolumns.length as length ...
常用 | 2008-04-12 14:03 | 阅读 2569 次 | 评论 0 条

ORM介绍

以下的ORM介绍来源网上(http://xclw.bokee.com/viewdiary.11582114.html) ORM,即Object-Relationl Mapping,它的作用是在关系型数据库和对象之间作一个映射,这样,我们在具体的操作数据库的时候,就不需要再去和复杂的SQL语句打交道,只要像平时操作对象一样操作它就可以了。 让我们从O/R开始。字母O起源于"对象"(Object),而R则来自于"关系"(Relational)。几乎所有的程序里面,都存在对象和关系数据库。在业务逻辑层和用户界面层中,我们是面向对象的。当对象信息发生变化的时候,我们需要把对象的信息保...
ORM | 2008-04-12 13:48 | 阅读 2774 次 | 评论 0 条

回车键代替Tab键

private void Form1_Load(object sender, EventArgs e) { this.KeyPreview = true;//让窗体接收键盘按键 } protected override void OnKeyPress(KeyPressEventArgs e) { base.OnKeyPress(e); if (DesignMode) return; if (e.KeyCha...
常用 | 2008-04-12 13:39 | 阅读 2195 次 | 评论 0 条

异常实现

public class AppException : Exception { public AppException() { } public AppException(string message) : base(message)//注意这里 { } public AppException(object invalidData, string message) : base(message + "\n数据:" + i...
常用 | 2008-04-12 13:38 | 阅读 2414 次 | 评论 0 条

远程数据访问

1、 创建一个远程对象(DLL):新建一个解决方案(类库),命名为RemoteObject 创建一个类 RemoteTest,代码如下 using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; namespace RemoteObject { public class RemoteTest : System.MarshalByRefObject//这是不能少的 { ...
高级编程 | 2008-04-12 13:36 | 阅读 1950 次 | 评论 0 条

反射

如果你封装了一个DLL,你可以用引用的方法去调用它,这是肯定的!你也可通过反射的方法去调用它! 例如: 新建一个类库项目,命名为 DLLForm,这个类库里面你可以添加一个窗体,命名为 “MyForm”。 在同一个解决方案里面添加一个应用程序,命名为MyApplication,并将其设为启动项 现在我们不直接引用DLLForm这个项目,而是通过反射来进行调用。 在窗体Form1中添加一个按钮事件,执行的代码如下 string[] arFile = System.IO.Directory.GetFiles(Application.StartupPath, "DLLFo...
高级编程 | 2008-04-12 13:33 | 阅读 1844 次 | 评论 0 条

读写XML

using System;using System.Xml;using System.Windows.Forms; namespace HVS.Common{ public class ReadXML { public static string GetXMLValueToString(string AppKey) { try { XmlDocument xDoc = new XmlDocument(); xDoc.Load(Applicati...
XML | 2008-04-11 13:33 | 阅读 1995 次 | 评论 0 条

一个非常好的 TextBox与Button组合体

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using HVS.WinUI.Forms; namespace HVS.WinUI.Components{ public partial class TextEdit : System.Windows.Forms.TextBox { #regi...
组件 | 2008-04-11 13:27 | 阅读 2896 次 | 评论 1 条

完美系统菜单

using System;using System.Drawing;using System.Runtime.InteropServices;using System.Diagnostics.CodeAnalysis; namespace HVS.Common{ public class Win32 { public struct MENUINFO { public int cbSize; public int fMask; public int dwStyle; ...
系统菜单 | 2008-04-11 13:24 | 阅读 2481 次 | 评论 0 条
浏览24956次