<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    飛艷小屋

    程序--人生--哲學___________________歡迎艷兒的加入

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      52 Posts :: 175 Stories :: 107 Comments :: 0 Trackbacks
     

    (一).功能描述

       涉及到DragEnter DragDrop DragLeave DragOver QueryContinueDrag事件用法的一個例子

    (二).代碼

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;

    namespace 拖放數據操作_按鍵事件_
    {
     /// <summary>
     /// Form1 的摘要說明。
     /// </summary>
     public class Form1 : System.Windows.Forms.Form
     {
      private System.Windows.Forms.Button button1;
      private System.Windows.Forms.TextBox textBox1;
      /// <summary>
      /// 必需的設計器變量。
      /// </summary>
      private System.ComponentModel.Container components = null;

      public Form1()
      {
       //
       // Windows 窗體設計器支持所必需的
       //
       InitializeComponent();

       //
       // TODO: 在 InitializeComponent 調用后添加任何構造函數代碼
       //
      }

      /// <summary>
      /// 清理所有正在使用的資源。
      /// </summary>
      protected override void Dispose( bool disposing )
      {
       if( disposing )
       {
        if (components != null)
        {
         components.Dispose();
        }
       }
       base.Dispose( disposing );
      }

      #region Windows 窗體設計器生成的代碼
      /// <summary>
      /// 設計器支持所需的方法 - 不要使用代碼編輯器修改
      /// 此方法的內容。
      /// </summary>
      private void InitializeComponent()
      {
       this.button1 = new System.Windows.Forms.Button();
       this.textBox1 = new System.Windows.Forms.TextBox();
       this.SuspendLayout();
       //
       // button1
       //
       this.button1.Location = new System.Drawing.Point(112, 72);
       this.button1.Name = "button1";
       this.button1.TabIndex = 0;
       this.button1.Text = "button1";
       this.button1.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.button1_QueryContinueDrag);
       this.button1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.button1_MouseDown);
       //
       // textBox1
       //
       this.textBox1.AccessibleDescription = "aaaaa";
       this.textBox1.AccessibleName = "bbbbbb";
       this.textBox1.AllowDrop = true;
       this.textBox1.Location = new System.Drawing.Point(64, 160);
       this.textBox1.Multiline = true;
       this.textBox1.Name = "textBox1";
       this.textBox1.Size = new System.Drawing.Size(168, 48);
       this.textBox1.TabIndex = 1;
       this.textBox1.Text = "";
       this.textBox1.DragOver += new System.Windows.Forms.DragEventHandler(this.textBox1_DragOver);
       this.textBox1.DragDrop += new System.Windows.Forms.DragEventHandler(this.textBox1_DragDrop);
       this.textBox1.DragEnter += new System.Windows.Forms.DragEventHandler(this.textBox1_DragEnter);
       this.textBox1.DragLeave += new System.EventHandler(this.textBox1_DragLeave);
       //
       // Form1
       //
       this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
       this.ClientSize = new System.Drawing.Size(292, 266);
       this.Controls.Add(this.textBox1);
       this.Controls.Add(this.button1);
       this.Name = "Form1";
       this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
       this.Text = "Form1";
       this.ResumeLayout(false);

      }
      #endregion

      /// <summary>
      /// 應用程序的主入口點。
      /// </summary>
      [STAThread]
      static void Main()
      {
       Application.Run(new Form1());
      }

      private void button1_QueryContinueDrag(object sender, System.Windows.Forms.QueryContinueDragEventArgs e)
      {
       if(e.EscapePressed)
        e.Action=DragAction.Cancel;
      }

      private void button1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
      {
       button1.DoDragDrop(button1.Text,DragDropEffects.Copy|DragDropEffects.Move);
      }

      private void textBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
      {
       if(e.Data.GetDataPresent(DataFormats.Text))
        e.Effect=DragDropEffects.Copy;
       else
        e.Effect=DragDropEffects.None;
      }

      private void textBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
      {
       //使用KeyState屬性
       if((e.KeyState&(1<<3))!=0)
       {
        if((e.AllowedEffect&DragDropEffects.Copy)!=0)
        {
         e.Effect=DragDropEffects.Copy;
         textBox1.Text=e.Data.GetData(DataFormats.Text).ToString();
        }
       }
       else
       {
        e.Effect=DragDropEffects.Move;
        textBox1.Text=e.Data.GetData(DataFormats.Text).ToString();
       }
      }

      private void textBox1_DragLeave(object sender, System.EventArgs e)
      {
       textBox1.Text="執行 DragLeave";
      }

      private void textBox1_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
      {
       textBox1.Text="執行 DragOver";
      }
     }
    }
     

    posted on 2005-12-08 14:25 天外飛仙 閱讀(332) 評論(0)  編輯  收藏 所屬分類: .net
    主站蜘蛛池模板: 免费人成视频在线观看网站| 大学生一级毛片免费看| 亚洲国产天堂久久综合网站| 97人妻无码一区二区精品免费| 亚洲熟妇成人精品一区| 亚洲精品成人片在线观看| 免费A级毛片无码视频| 日韩色日韩视频亚洲网站| 亚洲国产成人精品无码区在线观看| 国产精品视频免费观看| 高h视频在线免费观看| 亚洲一区二区中文| 国产一区二区视频免费| 久久久高清日本道免费观看| 亚洲精品伦理熟女国产一区二区| 亚洲成AV人在线观看天堂无码| 成人免费一区二区无码视频| 少妇性饥渴无码A区免费| 亚洲色精品VR一区区三区| 亚洲高清国产AV拍精品青青草原| 小小影视日本动漫观看免费| 日韩视频在线观看免费| jizzjizz亚洲日本少妇| 亚洲视频免费在线看| 亚洲欧洲国产成人综合在线观看 | 一级毛片在线免费播放| 久久精品国产亚洲AV久| 国产V亚洲V天堂无码久久久| 国产成人免费片在线视频观看| 亚洲免费人成视频观看| 中文在线观看国语高清免费| 亚洲精品第一国产综合亚AV| 亚洲第一精品福利| 国产自偷亚洲精品页65页| 国产福利免费在线观看| 一二三四免费观看在线视频中文版 | 亚洲国产精品尤物YW在线观看| 美女视频黄的全免费视频网站| 特级做A爰片毛片免费看无码 | 亚洲欧洲日韩国产| 亚洲小视频在线观看|