仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 607|回复: 7
打印 上一主题 下一主题

[学习教程] ASP.NET编程:用C#.NET完成拖放操纵

[复制链接]
活着的死人 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:42:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
刚刚打开这篇专题,猛然见到HAL9000发表的《对于大型公司项目平台选择j2ee的几层认识》系列,深受启发。在使用程序中,是经由过程处置一系列事务,如DragEnter,DragLeave和DragDrop事务来完成在Windows使用程序中的拖放操纵的。经由过程利用这些事务参数中的可用信息,能够轻松完成拖放操纵。
拖放操纵在代码中是经由过程三步完成的,起首是启动拖放操纵,在必要拖动数据的控件上完成MouseDown事务呼应代码,并挪用DoDragDrop()办法;其次是完成拖放效果,在方针控件上增加DragEnter事务呼应代码,利用DragDropEffects列举范例完成挪动或复制等拖动效果;最初是安排数据操纵,在方针控件上增加DragDrop呼应代码,把数据增加到方针控件中。
usingSystem;
usingSystem.Drawing;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Windows.Forms;
usingSystem.Data;
namespaceDragDrop
{
///<summary>
///Form1的择要申明。
///</summary>
publicclassForm1:System.Windows.Forms.Form
{
privateSystem.Windows.Forms.ListBoxlistBox1;
privateSystem.Windows.Forms.ListBoxlistBox2;
///<summary>
///必须的计划器变量。
///</summary>
privateSystem.ComponentModel.Containercomponents=null;
publicForm1()
{
//
//Windows窗体计划器撑持所必须的
//
InitializeComponent();
//
//TODO:在InitializeComponent挪用后增加任何机关函数代码
//
}
///<summary>
///清算一切正在利用的资本。
///</summary>
protectedoverridevoidDispose(booldisposing)
{
if(disposing)
{
if(components!=null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#regionWindows窗体计划器天生的代码
///<summary>
///计划器撑持所需的办法-不要利用代码编纂器修正
///此办法的内容。
///</summary>
privatevoidInitializeComponent()
{
this.listBox1=newSystem.Windows.Forms.ListBox();
this.listBox2=newSystem.Windows.Forms.ListBox();
this.SuspendLayout();
//
//listBox1
//
this.listBox1.ItemHeight=12;
this.listBox1.Location=newSystem.Drawing.Point(32,24);
this.listBox1.Name="listBox1";
this.listBox1.Size=newSystem.Drawing.Size(120,280);
this.listBox1.TabIndex=0;
this.listBox1.MouseDown+=newSystem.Windows.Forms.MouseEventHandler(this.listBox1_MouseDown);
//
//listBox2
//
this.listBox2.ItemHeight=12;
this.listBox2.Location=newSystem.Drawing.Point(248,24);
this.listBox2.Name="listBox2";
this.listBox2.Size=newSystem.Drawing.Size(120,280);
this.listBox2.TabIndex=0;
this.listBox2.DragDrop+=newSystem.Windows.Forms.DragEventHandler(this.listBox2_DragDrop);
this.listBox2.DragEnter+=newSystem.Windows.Forms.DragEventHandler(this.listBox2_DragEnter);
//
//Form1
//
this.AutoScaleBaseSize=newSystem.Drawing.Size(6,14);
this.ClientSize=newSystem.Drawing.Size(408,333);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.listBox2);
this.Name="Form1";
this.Text="Form1";
this.Load+=newSystem.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
///<summary>
///使用程序的主出口点。
///</summary>
[STAThread]
staticvoidMain()
{
Application.Run(newForm1());
}
privatevoidForm1_Load(objectsender,System.EventArgse)
{
this.listBox1.AllowDrop=true;
this.listBox2.AllowDrop=true;
this.listBox1.Items.Add("a");
this.listBox1.Items.Add("b");
this.listBox1.Items.Add("c");
}
privatevoidlistBox1_MouseDown(objectsender,System.Windows.Forms.MouseEventArgse)
{
this.listBox1.DoDragDrop(this.listBox1.Items[this.listBox1.SelectedIndex],DragDropEffects.Move);
}
privatevoidlistBox2_DragEnter(objectsender,System.Windows.Forms.DragEventArgse)
{
if(e.Data.GetDataPresent("Text"))
{
e.Effect=DragDropEffects.Move;
}
}
privatevoidlistBox2_DragDrop(objectsender,System.Windows.Forms.DragEventArgse)
{
this.listBox2.Items.Add(e.Data.GetData("Text"));
this.listBox1.Items.Remove(e.Data.GetData("Text"));
}
}
}
也许唯一可以让世人留恋Java的理由就剩下它的王牌——跨平台。
活着的死人 该用户已被删除
沙发
 楼主| 发表于 2015-1-19 21:29:57 | 只看该作者
目前在微软的.net战略中新推出的ASP.net借鉴了Java技术的优点,使用CSharp(C#)语言作为ASP.net的推荐语言,同时改进了以前ASP的安全性差等缺点。但是,使用ASP/ASP.net仍有一定的局限性,因为从某种角度来说它们只能在微软的WindowsNT/2000/XP+IIS的服务器平台上良好运行(虽然像ChilliSoft提供了在UNIX/Linux上运行ASP的解决方案.
第二个灵魂 该用户已被删除
板凳
发表于 2015-2-5 06:53:14 | 只看该作者
那么,ASP.Net有哪些改进呢?
海妖 该用户已被删除
地板
发表于 2015-2-11 07:22:49 | 只看该作者
我觉得什么语言,精通就好,你要做的就是比其他80%的人都厉害,你就能得到只有20%的人才能得到的高薪。
不帅 该用户已被删除
5#
发表于 2015-3-1 23:31:39 | 只看该作者
但是java靠开源打出的一片天地,特别是在微软的垄断下能打开今天的局面还是有它的生命力的。
深爱那片海 该用户已被删除
6#
发表于 2015-3-11 01:14:03 | 只看该作者
ASP.NET:ASP.net是Microsoft.net的一部分,作为战略产品,不仅仅是ActiveServerPage(ASP)的下一个版本;它还提供了一个统一的Web开发模型,其中包括开发人员生成企业级Web应用程序所需的各种服务。ASP.NET的语法在很大程度上与ASP兼容,同时它还提供一种新的编程模型和结构,可生成伸缩性和稳定性更好的应用程序,并提供更好的安全保护。
冷月葬花魂 该用户已被删除
7#
发表于 2015-3-17 17:52:25 | 只看该作者
可以通过在现有ASP应用程序中逐渐添加ASP.NET功能,随时增强ASP应用程序的功能。ASP.NET是一个已编译的、基于.NET的环境,可以用任何与.NET兼容的语言(包括VisualBasic.NET、C#和JScript.NET.)创作应用程序。另外,任何ASP.NET应用程序都可以使用整个.NETFramework。开发人员可以方便地获得这些技术的优点,其中包括托管的公共语言运行库环境、类型安全、继承等等。
山那边是海 该用户已被删除
8#
发表于 2015-3-24 16:25:23 | 只看该作者
JSP/Servlet虽然在国内目前的应用并不广泛,但是其前途不可限量。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-3 22:45

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表