c#对话框
OpenFileDialog open = new OpenFileDialog();//创建对话框
open.InitialDirectory = @"C:\Documents and Settings\All Users\桌面"; //设置对话框路径
open.Title = "对话框1"; //对话框标题
open.Filter = "文本文档|*.txt|所有文件|*.*";
open.Multiselect = true; //多选
open.ShowDialog(); //打开对话框
//string[] paths = open.FileName;
string paths = open.FileName; //读取文件的全路径
if (paths == "") return;
using (FileStream file = new FileStream(paths, FileMode.OpenOrCreate, FileAccess.Read))
{
byte[] bytes = new byte[1024 * 1024 * 5];
int r = file.Read(bytes, 0, bytes.Length);
this.textBox1.Text = Encoding.Default.GetString(bytes, 0, r);
}
int temp=0;
int[] a = { 23, 44, 66, 76, 98, 11, 3, 9, 7 };
for (int i = 0; i < a.Length; i++)
{
for (int j = 0; j < a.Length-i-1; j++)
{
if (a[j] < a[j + 1]) //从大到小
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
} }
Console.WriteLine("排序后的数组:");
foreach (int item in a)
{
Console.Write(item + " ");
}
Console.WriteLine();
Console.ReadKey();
SaveFileDialog sd=new SaveFileDialog(); //创建
// 保存文件对话框
sd.InitialDirectory = @"C:\Documents and Settings\All Users\桌面"; //设置对话框路径
sd.Title = "对话框1"; //对话框标题
sd.Filter = "文本文档|*.txt|所有文件|*.*";
sd.ShowDialog();
string path = sd.FileName;
using (FileStream fsv = new FileStream(path, FileMode.Create, FileAccess.Write))
{
byte[] bytes = Encoding.Default.GetBytes(this.textBox1.Text);
fsv.Write(bytes, 0, bytes.Length);
}
private void button3_Click(object sender, EventArgs e)
{
FontDialog fonts = new FontDialog(); fonts.ShowDialog();
this.textBox1.Font = fonts.Font;
} private void button4_Click(object sender, EventArgs e)
{
ColorDialog color = new ColorDialog();
color.ShowDialog();
this.textBox1.BackColor = color.Color;
this.textBox1.ForeColor = color.Color;
}
c#对话框的更多相关文章
- 一步步开发自己的博客 .NET版(10、前端对话框和消息框的实现)
关于前端对话框.消息框的优秀插件多不胜数.造轮子是为了更好的使用轮子,并不是说自己造的轮子肯定好.所以,这个博客系统基本上都是自己实现的,包括日志记录.响应式布局.评论功能等等一些本可以使用插件的.好 ...
- jQuery遮罩层登录对话框
用户登录是许多网站必备的功能.有一种方式就是不管在网站的哪个页面,点击登录按钮就会弹出一个遮罩层,显示用户登录的对话框.这用方式比较灵活方便.而现在扫描二维码登录的方式也是很常见,例如QQ.微信.百度 ...
- Android系统默认对话框添加图片
开发工具Android Studio 今天公司UI要求软件对话框改成加图片的,以前没有做过,所以就学习了一下,废话不多说, 看效果: 创建XML文件dialog_lsit_item.xml <L ...
- Android—关于自定义对话框的工具类
开发中有很多地方会用到自定义对话框,为了避免不必要的城府代码,在此总结出一个工具类. 弹出对话框的地方很多,但是都大同小异,不同无非就是提示内容或者图片不同,下面这个类是将提示内容和图片放到了自定义函 ...
- 使用CSS3的box-shadow实现双透明遮罩层对话框
box-shadow介绍 在我之前的一篇文章<从天猫和支付宝身上学习opcity与rgba>中,介绍了实现双透明遮罩层效果的两种方法,分别是opacity和rgba.他们需要分别依赖于不同 ...
- 10.JAVA之GUI编程弹出对话框Dialog
在上节基础上添加对话框显示错误信息. 代码如下: /*弹出对话框显示错误信息,对话框一般不单独出现,一般依赖于窗体.*/ /*练习-列出指定目录内容*/ import java.awt.Button; ...
- C#WebBrowrse拦截下载对话框
为了实现这个功能,可算是折腾不少时间,网上搜素出来的结果基本都是如何屏蔽警告对话框.后来请教一个技术大牛(程序员之窗的主要作者Starts_2000),他用C++实现了,他尝试了下C#也没有解决,就忙 ...
- 实现对gridview删除行时弹出确认对话框的一种简单方法
在VS2008提供的GridView中我们可以直接添加一个CommandField删除列:<asp:CommandField ShowDeleteButton="True" ...
- 炫酷的jQuery对话框插gDialog
js有alert,prompt和confirm对话框,不过不是很美体验也不是很好,用jQuery也能实现, 体验效果:http://hovertree.com/texiao/jquery/34/ 代码 ...
- Android中的AlertDialog使用示例五(自定义对话框)
在Android开发中,我们经常会需要在Android界面上弹出一些对话框,比如询问用户或者让用户选择.这些功能我们叫它Android Dialog对话框,AlertDialog实现方法为建造者模式. ...
随机推荐
- Baseline管理
1.创建基线 SQL> exec dbms_workload_repository.create_baseline(start_snap_id=>,end_snap_id=>,bas ...
- duplicate命令创建physical standby数据库报RMAN-03015 ORA-17628
The following error is reported trying to create a Physical Standby database using "duplicate f ...
- mysql explain输出中type的取值说明
原文: http://www.cnitblog.com/aliyiyi08/archive/2008/09/09/48878.html 这列很重要,显示了连接使用了哪种连接类别,有无使用索引. 从最好 ...
- Java基础之读文件——使用输入流读取二进制文件(StreamInputFromFile)
控制台程序,读取Java基础之读文件部分(StreamOutputToFile)写入的50个fibonacci数字. import java.nio.file.*; import java.nio.* ...
- CocoaPods看的三篇文章
http://www.bubuko.com/infodetail-425274.html//有图片 http://www.cnblogs.com/jys509/p/4839803.html http: ...
- iOS架构网址
http://casatwy.com/iosying-yong-jia-gou-tan-kai-pian.html
- M面经Prepare: Find integer Average of 2 integers.
The definition of integer average is the highest smaller integer if average is floating point number ...
- [原创]java WEB学习笔记65:Struts2 学习之路--Struts的CRUD操作( 查看 / 删除/ 添加) ModelDriven拦截器 paramter 拦截器
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- 分享Centos作为WEB服务器的防火墙规则
# Firewall configuration written by system-config-firewall # Manual customization of this file is no ...
- C# 控制台程序如何防止启动多个实例
==================================================================================================== ...