首页 ┆ 网站地图 ┆ 在线留言 ┆ 游戏资讯 ┆ 资源下载 ┆ 端午节祝福 ┆ 迅雷在线影视 ┆淘宝手机在线充值 ┆淘宝游戏点卡充值 
设为首页
加入收藏
联系我们
高级搜索
您当前的位置: 主页>NET专区>ASP.NET>asp.NET开发中常用的25个小技巧
asp.NET开发中常用的25个小技巧
来源: 发布时间:2008-04-08 发布人: 浏览: 人次   字体: [ ]  
1.   如何创建一个可改变大小没有标题栏的窗体?(How   to   create   a   form   with   resizing   borders   and   no   title   bar?)  

form1.Text   =   string.   Empty;  
form1.ControlBox   =   false;  

2.   如何在.NET的Windows窗体上启用XP主题集?(How   to   use   XP   Themes   with   Windows   Forms   using   the   .NET?)  

确认你的控件中FlatStyle属性已经修改为System,再修改Main方法。  

static   void   Main()  
{  
Application.EnableVisualStyles();  
Application.DoEvents();  
Application.   Run(new   Form1());  
}  

3.   如何为一个窗体设置一个默认按钮?(How   to   set   the   default   button   for   a   form?)  

form1.AcceptButton   =   button1;  

4.   如何为一个窗体设置一个取消按钮?(How   to   set   the   Cancel   button   for   a   form?)  

form1.CancelButton   =   button1;  

5.   如何阻止一个窗体标题显示在任务栏上?(How   to   prevent   a   form   from   being   shown   in   the   taskbar?)  

设置窗体的ShowIntaskbar属性为False  

6.   如何用现有可用字体绑定到ComboBox控件?(How   to   fill   a   ComboBox   with   the   available   fonts?)  

comboBox1.Items.AddRange   (FontFamily.Families);  

7.   如何禁止TextBox控件默认的邮件菜单?(How   to   disable   the   default   ContextMenu   of   a   TextBox?)  

textBox1.ContextMenu   =   new   ContextMenu   ();  

8.   如何获取“我的文档”等一些系统文件夹路径?(How   to   get   the   path   for   "My   Documents "   and   other   system   folders?)  

Environment.SpecialFolder中包含了一些系统文件夹信息  
MessageBox.Show(Environment.GetFolderPath(   Environment.SpecialFolder.Personal   ));  

9.   如何获取应用程序当前执行的路径?(How   to   get   the   path   to   my   running   EXE?)  

string   appPath   =   Application.ExecutablePath;  

10.   如何确定当前运行的系统?(How   to   determine   which   operating   system   is   running?)  

OperatingSystem   os   =   Environment.OSVersion;  
MessageBox.Show(os.Version.ToString());  
MessageBox.Show(os.Platform.ToString());  

11.   如何从完整的路径中获取文件名?(How   to   get   a   file 's   name   from   the   complete   path   string?)  

用System.IO.Path.GetFileName   和   System.IO.Path.GetFileNameWithoutExtension(无扩展名)的方法  

12.   如何从完整的路径中获取文件扩展名?(How   to   get   a   file 's   extension   from   the   complete   path   string?)  

用System.IO.Path.GetExtension方法  

13.   如何使没有选择日期的DateTimePicker控件为空文本?(How   to   make   the   DateTimePicker   show   empty   text   if   no   date   is   selected?)  

dateTimePicker1.CustomFormat   =   "   ";  
dateTimePicker1.Format   =   DateTimePickerFormat.Custom;  

14.   如何在Report   Viewer中隐藏Crystal   Report的状态栏?(How   to   hide   the   status   bar   of   Crystal   Report   in   Report   Viewer?)  

foreach(object   obj   in   this.crystalReportViewer1.Controls)  
{  
if(   obj.GetType()==   typeof(System.Windows.Forms.StatusBar))  
{  
StatusBar   sBar=(StatusBar)obj;  
sBar.Visible=false;  
}  
}  

15.   如何利用Crystal   Report程序来生成PDF版本?(How   to   generate   PDF   version   of   Crystal   Report   programmatically?)  

ReportDocument   O_Report=new   ReportDocument();  
ExportOptions   exportOpts   =   new   ExportOptions();  
PdfRtfWordFormatOptions   pdfFormatOpts   =   new   PdfRtfWordFormatOptions   ();  
DiskFileDestinationOptions   diskOpts   =   new   DiskFileDestinationOptions();  
exportOpts   =   O_Report.ExportOptions;  
//   设置PDF格式  
exportOpts.ExportFormatType   =   ExportFormatType.PortableDocFormat;  
exportOpts.FormatOptions   =   pdfFormatOpts;  
//   设置文件选项和导出  
exportOpts.ExportDestinationType   =   ExportDestinationType.DiskFile;  
diskOpts.DiskFileName   =   "C://Trial.pdf ";   //设置PDF导出路径  
exportOpts.DestinationOptions   =   diskOpts;  
O_Report.Export   ();  

16.通过代码如何输入多行文本?(How   to   enter   multiline   text   in   textbox   through   code?   )  

利用TextBox控件的LINES属性  
string   []   strAddress   =   { "Mukund   Pujari ", "Global   Transformation   Technologies ", "Pune,   India "};  
textBox1.MultiLine=true;  
textBox1.Lines=strAddress;  

或者  
textBox1.Text= "Line   1\r\nLine2\r\nLine3. ";  

或者  
用 "System.Environment.NewLine "来替代换行符号  

17.   如何在DataGrid中去掉CheckBox不确定状态?(How   to   remove   the   indeterminate   status   of   checkbox   in   datagrid?)  

DataGridTableStyle   ts1   =   new   DataGridTableStyle();   //创建Table样式  
ts1.MappingName   =   "Items ";   //分配要应用样式的Data   Table  
DataGridColumnStyle   boolCol   =   new   DataGridBoolColumn();   //   创建CheckBox列  
boolCol.MappingName   =   "ch ";   //分配数据列名称  
boolCol.AllowNull=false;   //   修改AllowNull属性  

共2页: 上一页 1 [2] 下一页
相 关 文 章   发布商链接
·asp.net将上传图片增加水印并写入数...
·asp.net中HttpModule是如何工作的?附...
·Response.Redirect在新窗口打开的新...
·.net 如何得到某日是一年的第几周
·ASP.net获取SQL server数据库image类...
·一个可自动适应高度的TextBox,附代码
·ASP.NET中实现单点登录思路及其代码
·图解asp.net如何用excel做报表的实例
·ASP.NET利用dot模板生成Word文档代码
·ASP.NET资源文件夹的具体介绍
 §最新评论:(评论内容只代表网友观点,与本站立场无关!)
网名: 验证码:  【所有评论】【↑返回顶部
评 分: 12 345
评论内容:(不能超过500字,请自觉遵守互联网相关政策法规。[按 Ctrl+Enter 可直接提交]
注意:请勿在本站发布政治话题、色情及违反法律的内容。
IT知道网 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。
推 荐 文 章
·实例讲解ASP.NET实现加密Cook...
·如何实现在DataList控件中的D...
·实例讲解asp.net生成高质量缩
·asp.net适用于IE或FireFox的...
·举例详解C#代码与javaScript...
·asp.net无刷新上传文件
·在Ie中保存图片时出现"800700...
·asp.net文件上传大小限制的控
·asp.net动态生成txt文本文件...
·asp.net实现将Excel文件导入...
·实现多列,带图片的DropDownLi...
·javascript实现TreeView 控件
·ASP.NET配置Word的操作权限
·让FileUpload控件在IE和FireF...
·ASP.NET实现Office文档的分类
热 门 文 章
·asp.net(C#)上传下载及文件管...
·图解asp.net如何用excel做报...
·asp.net无刷新上传文件
·Asp.Net防止刷新重复提交数据...
·asp.net实现将Excel文件导入...
·ASP.NET取得物理路径和虚拟路...
·asp.net中Web.Config配置文件...
·asp.net(c#)生成验证码代码,...
·asp.net页面回传与js调用服务...
·asp.net中DataBinder.Eval的...
·asp.net(C#版)实现登录验证码...
·DataGrid中DropDownList触发S...
·asp.net可输入的下拉框复合控...
·ASP.net 实现批量数据更新或...
·asp.net中常见的几种日历控件...
网站首页 - 关于本站 - 加入收藏 - 网站地图 - 友情连接 - 在线留言 - 联系我们 - 返回顶部
Copyright © 2007 IT知道网.[冀ICP备07026896号]. All Rights Reserved .