⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 一个通讯录源码,用C#写的.挺不错的,大家可以参考看一下.
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.Common;
using System.Runtime.InteropServices;
using System.Windows.Forms.Design;

namespace AddressList.Forms
{
    public partial class Form1 : fmBaseForm
    {
        public Form1()
        {
            InitializeComponent();
        }

        [DllImport("User32.Dll")]
        public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

        [DllImport("user32")]
        private static extern IntPtr GetWindowDC(IntPtr hWnd);

        [DllImport("user32")]
        private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

        [DllImport("User32")]
        private static extern bool DrawFrameControl(IntPtr DC, Rectangle Rect, int uType, int uState);

        protected override void DefWndProc(ref Message m)
        {
            base.DefWndProc(ref m);
            //if (m.Msg == WM.WM_TEST)
            //{
            //    textBox1.Text = "WM_TEST";
            //}
        }

        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);            
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            DataSet dataset= new DataSet();
            DataAdapter dap = DBConn.DBDataAdapter("SELECT A.FNumber, A.FName, A.FItemID, B.FName AS GroupName " +
                "FROM t_Friend AS A INNER JOIN t_FriendGroup AS B ON A.FParentID = B.FInterID");
            dap.Fill(dataset);
            listView1.BeginUpdate();
            try
            {
                DataTable table = dataset.Tables[0];
                for (int I = 0; I < table.Columns.Count; I++)
                {
                    ListViewItem lvItem = new ListViewItem();

                    DataColumn colum = table.Columns[I];

                    lvItem.Text = colum.Table.TableName;

                    lvItem.SubItems.Add(colum.ColumnName);
                    lvItem.SubItems.Add(colum.Expression);

                    listView1.Items.Add(lvItem);
                }
            }
            finally
            {
                listView1.EndUpdate();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.DrawString("字符串", Font, Brushes.Black, new PointF(10, 10));
            comboBox1.BeginUpdate();
            try
            {
                foreach (FontFamily oneFontFamily in FontFamily.Families)
                {
                    comboBox1.Items.Add(oneFontFamily.Name);
                }                
            }
            finally
            {
                comboBox1.EndUpdate();
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            //SendMessage(this.Handle, WM.WM_TEST, 0, 0); 
        }

        /// <summary>
        /// 打印预览
        /// </summary>
        private void button4_Click(object sender, EventArgs e)
        {

        }

        
        private void DrawDropDownButton(IntPtr DC, Rectangle ARect, bool Enabled, bool Flat, bool Active, bool Down)
        {

            /*int Flags;
            Details: TThemedElementDetails;

            if ThemeServices.ThemesEnabled then
            begin
              if not Enabled then
                Details := ThemeServices.GetElementDetails(tcDropDownButtonDisabled)
              else
                if Down then
                  Details := ThemeServices.GetElementDetails(tcDropDownButtonPressed)
                else
                  if Active
                    then Details := ThemeServices.GetElementDetails(tcDropDownButtonHot)
                    else Details := ThemeServices.GetElementDetails(tcDropDownButtonNormal);
              ThemeServices.DrawElement(DC, Details, ARect);
            end else
            begin
              Flags := DownFlags[Down] or FlatFlags[Flat] or EnabledFlags[Enabled];
              DrawFrameControl(DC, ARect, DFC_SCROLL, Flags or DFCS_SCROLLCOMBOBOX);
            end;
          end;

              */
        }
    }

    //public class WM
    //{
    //    public const int WM_USER = 0x0400;
    //    public const int WM_TEST = WM_USER + 100;
    //}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -