启动SQL Server 2008 Management Studio 工具菜单—-选项—-Designers(设计器)—-阻止保存要求重新创建表的更改 取消勾选即可。 转自:http://www.cnblogs.com/EasyLive2006/archive/2009/01/13/1375182.html
View Details服务器端包含的指令和使用程序本节介绍IIS 5.0服务器端包含的指令的语法和参数值。还介绍IISRESTART实用程序的语法和使用,该实用程序可用来从远程计算机、命令行和SSI指令的内部管理Web服务器。 1. SSI指令、属性和标记指令 说明#include 将指定的文件内容插入到被发送到客户机的响应流中,并替换该指令。例如:<!-- #include file=”userfilbits.inc”à#config 指定用于日期、时间和文件尺寸的格式,以及返回客户机的通用SSI错误消息的文本格式。例如:<!—#config ERRMSG=”SSI Processing Error”à<!—#config TIMEFMT=”%A, %B, %d, %Y, %H:%M:%S ”à<!—#config SIZEFMT=”BYTES”à参见下文中关于用于该指令的属性和标记的列表#echo 将HTTP环境变量插入到发送给客户机的相应流中,并替换该指令。例如:<!--#echo VAR-“SERVER_NAME”à参见下文中关于用于该指令的属性和标记的列表#exec 在服务器上执行一个程序或shell命令。例如:<!--#execCGI=”/scripts/myapp.exe?value1=this&value2=that”à<!--#exec CMD=”cmd.exe /c iisrestart /stop”à<!--#exec CMD=”cmd.exe /c net start cisvc”à参加下文中关于该指令的属性和标记列表。必须添加以下条目到Windows Registry中才可以使用CMD属性:HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/W3SVC/Parameters/SSIEnableCmdDirective将该值设置为1并重新启动WWW服务,CMD属性才被允许用于#exec指令。将其设置为0则禁止它并防止未验证的使用,否则将会破坏服务器的安装。#flastmod 将指定文件的最新更改的日期和时间插入到要发送客户机的响应流中。例如:<!--#flastmod file=”default.asp”à参见下文中关于该指令的属性和标记的列表。#fsize 将指定文件的尺寸插入到要发送给客户机的响应流中。例如:<!--#fsize file=”default.asp”à参见下文中关于该指令的属性和标记的列表。2. #exec指令的命令类型属性属性 说明CGI 在Web服务器上下文中执行指定的应用(即通过ISAPI对请求和响应的访问),并将任何查询串的值传递到应用中。该应用与Web服务器运行在不同的内存中CMD 启动指定的操作系统命令的解释程序的一个实例,并执行该指令的命令3. #cinlcude、#flastmod和#fsiaze的路径类型属性属性 说明FILE 该属性的值是绝对和相对路径加上文件名,就像在DOS命令提示中所使用的,如“/files/web/myfile.txt”VIRTUAL 该属性值是绝对路径和相对路径加上文件名,与当前的Web站点的根文件夹相关。如“/file/web/myfile.txt”4. #config指令的SIZEFMT标记标记 说明BYTES 文件大小将以字节返回ABBEV 文件大小将以计算并以最近的千字节(KB)数返回5. #config指令的TIMEFMT标记标记 说明%a 一周的日子按”Mon”、”Tue”等表示%A 一周的日子按”Monday”、”Tuesday”等表示%b 月份名按”Jan”、”Feb”等表示%B 月份名按”January”、”February”等表示%c 与服务器的地区相对应的当前的日期和时间格式(如11/06/99 12:51:32)%d 一月的日子按数表示(01到31)%H 用24小时格式表示当前时间(00到23)%I 用12小时格式表示当前时间(01到12)%j 按数字(001到366)表示一年的日子%m 月份按数字表示(01到12)%M 当前分钟按数字表示(00到59)%p 按服务器地区表示相应的“上午”或“下午”文字如(AM或PM)%S 当前的秒按数字表示(00到59)%U 一年的每周按数字表示(00到51),并且每周的第一天为Sunday%w 一周每天按数字表示(0到6),并且每周的第一天为Sunday%W 一年的没有数字表示(00到51),并且每周的第一天为Monday%x 当前的日期格式对应于服务器地区表示的(如11/06/99)%X 当前时间格式相应与服务器地区表示的(12:51:32)%y 没有世纪表示的年数(如01)%Y 有世纪表示的年数(如2001)%z,%Z 服务器时间带的名字或缩写(如果知道的话)%% 百分号字符6. #echo指令的VAR标记标记 说明AUTH_TYPE 客户机用来验证网页是否拒绝匿名访问的验证类 型,如“Basic”或“NTLM”(即,询问/响应)AYTH_PASSWORD 由用户向服务器提供的口令,如果该页拒绝匿名访问并且客户机使用Basic方法验证的话AUTH_USER 由用户向服务器提供的用户名,如果在NTLM和Basic(或其他)方法下该页拒绝匿名访问的话CONTENT_LENGTH 在请求体中发送的字节数,即,作为POST向服务器发送的字节数CONTENT_TYPE 作为POST在请求体中发送的数据MIME类型DOCUMENT_NAME 由客户机请求的文档的全实际路径和文件名DOCUMENT_URT 由客户机请求的文档的全虚拟路径和文件名DATE_GMT 服务器操作系统中的日期和时间设置,不带任何Greenwich Mean Time的调节DATE_LOCAL Greenwich Mean […]
View DetailsBasic SSI directives Syntax
1 |
<!--#element attribute=value attribute=value ... --> |
Today’s date
1 |
<!--#config timefmt="%Y/%m/%d %a %H:%M:%S" -->Today is <!--#echo var="DATE_LOCAL" --> |
Modification date of the file
1 |
This document last modified <!--#flastmod file="index.html" --> |
Including the results of a CGI program
1 |
<!--#include virtual="/cgi-bin/counter.pl" --><!--#include virtual="/cgi-bin/example.cgi?argument=value" --> |
You can use "#exec cgi=" directive, but it can be disabled using the IncludesNOEXEC Option. Including a standard footer
1 |
<!--#include virtual="/footer.html" --> |
Executing commands
1 |
<!--#exec cmd="ls" --> |
This feature is dangerous. You can allow SSI, but not the exec feature, with the IncludesNOEXEC argument to the Options directive. Setting variables
1 |
<!--#set var="modified" value="$LAST_MODIFIED" --><!--#set var="date" value="${DATE_LOCAL}_${DATE_GMT}" --> |
Conditional expressions
1 |
<!--#if expr="test_condition" --><!--#elif expr="test_condition" --><!--#else --><!--#endif --> |
View Details
yield 关键字向编译器指示它所在的方法是迭代器块。 编译器生成一个类来实现迭代器块中表示的行为。 在迭代器块中,yield 关键字与 return 关键字结合使用,向枚举器对象提供值。 这是一个返回值,例如,在 foreach 语句的每一次循环中返回的值。 yield 关键字也可与 break 结合使用,表示迭代结束。 有关迭代器的更多信息,请参见迭代器(C# 编程指南)。 下面的示例演示两种形式的 yield 语句。 示例:
1 |
<ol class="dp-c"><li class="alt"><span><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> List </span></span></li><li><span>{ </span></li><li class="alt"><span> <span class="comment">//using System.Collections;</span><span> </span></span></li><li><span> <span class="keyword">public</span><span> </span><span class="keyword">static</span><span> IEnumerable Power(</span><span class="keyword">int</span><span> number, </span><span class="keyword">int</span><span> exponent) </span></span></li><li class="alt"><span> { </span></li><li><span> <span class="keyword">int</span><span> counter = 0; </span></span></li><li class="alt"><span> <span class="keyword">int</span><span> result = 1; </span></span></li><li><span> <span class="keyword">while</span><span> (counter++ < exponent) </span></span></li><li class="alt"><span> { </span></li><li><span> result = result * number; </span></li><li class="alt"><span> yield <span class="keyword">return</span><span> result; </span></span></li><li><span> } </span></li><li class="alt"><span> } </span></li><li><span> </span></li><li class="alt"><span> <span class="keyword">static</span><span> </span><span class="keyword">void</span><span> Main() </span></span></li><li><span> { </span></li><li class="alt"><span> <span class="comment">// Display powers of 2 up to the exponent 8:</span><span> </span></span></li><li><span> <span class="keyword">foreach</span><span> (</span><span class="keyword">int</span><span> i </span><span class="keyword">in</span><span> Power(2, 8)) </span></span></li><li class="alt"><span> { </span></li><li><span> Console.Write(<span class="string">"{0} "</span><span>, i); </span></span></li><li class="alt"><span> } </span></li><li><span> } </span></li><li class="alt"><span>} </span></li><li><span><span class="comment">/*</span> </span></li><li class="alt"><span><span class="comment">Output:</span> </span></li><li><span><span class="comment">2 4 8 16 32 64 128 256 </span> </span></li><li class="alt"><span><span class="comment">*/</span><span> </span></span></li></ol> |
环境: windows server 2003 、 iis6.0 、 php5.3.2 、 fcgi_1.5_x86 在winodws server 2003 上利用iis6.0搭建web服务器,采用php-cgi模式运行php脚本,提示如下错误!错误提示: FastCGI ErrorThe FastCGI Handler was unable to process the request.——————————————————————————– Error Details: Error Number: 14001 (0x800736b1).Error Description: 由于应用程序配置不正确,应用程序未能启动。重新安装应用程序可能会纠正这个问题。HTTP Error 500 – Server Error.Internet Information Services (IIS) 错误可能原因: 一.没有安装.net 2.0 的框架 二.没有安装VC9运行库即VISUAL C++ 2008 解决方法:⒈安装2.0版本以上的.net Framework.net Framework下载地址:页面地址:http://www.microsoft.com/downloads/zh-cn/details.aspx?FamilyID=D0E5DEA7-AC26-4AD7-B68C-FE5076BBA986软件地址:http://download.microsoft.com/download/2/0/E/20E90413-712F-438C-988E-FDAA79A8AC3D/dotnetfx35.exe⒉安装VC9运行库即VISUAL C++ 2008,Microsoft Visual C++ 2008 Redistributable Package (x86)下载地址:页面地址:http://www.microsoft.com/downloads/details.aspx?FamilyID=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF&displaylang=zh-cn软件地址:http://download.microsoft.com/download/7/5/0/7502f4e9-1f90-4895-9259-1bde67b8b9a1/vcredist_x86.exe ⒊安装完成后重新启动iis 转自:http://www.huqiang.name/2012/05/03/archives/1678.html
View DetailsFastCGI的IIS模块可以让流行的应用框架在IIS上支持FastCGI协议以提供高性能和可用性的访问服务,FastCGI面向现有的网络服务器提供高性能的CGI替代标准。具体PHP 安装方法我记录下来,其中包括出现的一个错误.环境: 操作系统:Windows 2003 Server PHP版本:PHP5.25 1.下载FastCGI For IIS6 http://www.microsoft.com/downloads/details.aspx?FamilyID=2d481579-9a7c-4632-b6e6-dee9097f9dc5&displaylang=en 下载之后,双击运行进行安装. 2.下载PHP5.25 Windows版 http://www.php.net 下载.zip格式的版本,下载后解压至D:\PHP目录,并给IIS启动帐户组或用户赋予读取和运行权限. 3.注册PHP到FastCGI 在命令行下运行 cscript fcgiconfig.js -add -section:"PHP" -extension:php -path:"D:\PHP\php-cgi.exe" fcgiconfig.js 默认存放目录是:C:\WINDOWS\system32\inetsrv 4.设置 将D:\PHP\php.ini-recommended重命名为为D:\PHP\php.ini 打开D:\PHP\php.ini,修改: extension_dir = "D:\PHP\ext" fastcgi.impersonate = 1 cgi.fix_pathinfo=1 cgi.force_redirect = 0 其它根据实际需要对php.ini进行设置修改 然后执行: cscript fcgiconfig.js -set -section:"PHP" -InstanceMaxRequests:500 cscript fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:1000 以上两项设置最大池和响应连接数,可以根据运行机器的硬件配置、使用情况修改 一切完毕之后重启IIS,赶紧写一个测试页试一下吧. 我第一次安装时,由于为了服务器的安全我删除了wsshell命令,导致在第3步时出现了如下错误: Microsoft JScript 运行时错误: Automation 服务器不能创建对象 后通过重新注册命令:regsvr32 WSHom.ocx 问题解决 重启IIS后,打开测试页出现如下提示: FastCGI Error The FastCGI Handler was unable to process the request. ——————————————————————————-- Error Details: Error Number: 5 (0x80070005). Error Description: 拒绝访问。 HTTP Error 500 – Server Error. Internet Information Services (IIS) 这个错误是由于在解压PHP之后,没有对IIS启动帐户赋予该目录的读取和运行权限.修改文件夹安全属性,问题解决. 转自:http://www.jb51.net/article/16953.htm
View Details安装:mongod --dbpath "C:\mongodb\db" --logpath "C:\mongodb\log.txt" --install --serviceName "MongoDB" 卸载:mongod.exe --remove --serviceName "MongoDB" 服务 错误 1053 您可以编辑在注册表中的可执行文件的路径,通过改变在以下关键的ImagePath HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MongoDB\ImagePath 数值数据位 "D:\xampp\mongodb\bin\mongod.exe" --bind_ip 127.0.0.1 --logpath "d:\xampp\mongodb\dblog" --logappend --dbpath "d:\xampp\mongodb\data" --directoryperdb --serviceName MongoDB --service
View Details取出richTextBox里面的内容第一种方法:将richTextBox的内容以字符串的形式取出string xw = System.Windows.Markup.XamlWriter.Save(richTextBox.Document);第二种方法:将richTextBox的类容以二进制数据的方法取出FlowDocument document = richTextBox.Document;System.IO.Stream s = new System.IO.MemoryStream(); System.Windows.Markup.XamlWriter.Save(document, s); byte[] data = new byte[s.Length];s.Position = 0;s.Read(data, 0, data.Length);s.Close(); 赋值给richTextBox 第一种方法:将字符串转换为数据流赋值给richTextBox中 System.IO.StringReader sr = new System.IO.StringReader(xw);System.Xml.XmlReader xr = System.Xml.XmlReader.Create(sr);richTextBox1.Document = (FlowDocument)System.Windows.Markup.XamlReader.Load(xr);第二种方法:将二进制数据赋值给richTextBoxSystem.IO.Stream ss = new System.IO.MemoryStream(data);FlowDocument doc = System.Windows.Markup.XamlReader.Load(ss) as FlowDocument;ss.Close();richTextBox1.Document = doc; 清空RichTextBox的方法 System.Windows.Documents.FlowDocument doc = richTextBox.Document;doc.Blocks.Clear(); 如何将一个String类型的字符串赋值给richTextBoxmyRTB.Document = new FlowDocument(new Paragraph(new Run(myString))); FlowDocument doc = new FlowDocument();Paragraph p = new Paragraph(); // Paragraph 类似于 html 的 P 标签Run r = new Run(myString); // Run 是一个 Inline 的标签p.Inlines.Add(r);doc.Blocks.Add(p);myRTB.Document = […]
View Details给大家讲到WPF,我们就不得不提到WinForm,51CTO之前也报导过《WPF与WinForm对比谈 多线程编程优化是关键》的技术文章,对于他们之间的优劣有了更深刻的认识。而今天我们要讲到的是WPF 4中的DataGrid空间。我们也诚挚向您推荐《让你的代码“炫”起来——WPF开发教程》。 提到DataGrid 不管是网页还是应用程序开发都会频繁使用。通过它我们可以灵活的在行与列间显示各种数据。本篇将详细介绍WPF 4 中DataGrid 的相关功能。 自定义列 默认情况下,当我们为DataGrid 控件设置ItemSource 属性后,DataGrid 会根据数据类型自动生成相应的列,下表列出DataGrid 支持的四种列及其数据类型。 在创建DataGrid 时可以通过AutoGenerateColumns 属性设置列是否自动生成,从而加入自定义列。如果DataGrid 中同时包含“自动生成列”与“用户自定义列”,则首先创建“用户自定义列”。下面代码实例中分别创建这四种列:
1 |
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">Window</span><span> </span><span class="attribute">x:Class</span><span>=</span><span class="attribute-value">"WPF4ControlTest.MainWindow"</span><span> </span></span></li><li><span> </span><span class="attribute">xmlns</span><span>=</span><span class="attribute-value">"http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span><span> </span></li><li class="alt"><span> </span><span class="attribute">xmlns:x</span><span>=</span><span class="attribute-value">"http://schemas.microsoft.com/winfx/2006/xaml"</span><span> </span></li><li><span> </span><span class="attribute">xmlns:local</span><span>=</span><span class="attribute-value">"clr-namespace:WPF4ControlTest"</span><span> </span></li><li class="alt"><span> </span><span class="attribute">xmlns:assembly</span><span>=</span><span class="attribute-value">"clr-namespace:System;assembly=mscorlib"</span><span> </span></li><li><span> </span><span class="attribute">Title</span><span>=</span><span class="attribute-value">"MainWindow"</span><span> </span><span class="attribute">Height</span><span>=</span><span class="attribute-value">"200"</span><span> </span><span class="attribute">Width</span><span>=</span><span class="attribute-value">"500"</span><span class="tag">></span><span> </span></li><li class="alt"><span> </span><span class="tag"><</span><span class="tag-name">Window.Resources</span><span class="tag">></span><span> </span></li><li><span> </span><span class="tag"><</span><span class="tag-name">ObjectDataProvider</span><span> </span><span class="attribute">x:Key</span><span>=</span><span class="attribute-value">"sexEnum"</span><span> </span><span class="attribute">MethodName</span><span>=</span><span class="attribute-value">"GetValues"</span><span> </span></li><li class="alt"><span> </span><span class="attribute">ObjectType</span><span>=</span><span class="attribute-value">"{x:Type assembly:Enum}"</span><span class="tag">></span><span> </span></li><li><span> </span><span class="tag"><</span><span class="tag-name">ObjectDataProvider.MethodParameters</span><span class="tag">></span><span> </span></li><li class="alt"><span> </span><span class="tag"><</span><span class="tag-name">x:Type</span><span> </span><span class="attribute">Type</span><span>=</span><span class="attribute-value">"local:SexOpt"</span><span class="tag">/></span><span> </span></li><li><span> </span><span class="tag"></</span><span class="tag-name">ObjectDataProvider.MethodParameters</span><span class="tag">></span><span> </span></li><li class="alt"><span> </span><span class="tag"></</span><span class="tag-name">ObjectDataProvider</span><span class="tag">></span><span> </span></li><li><span> </span><span class="tag"></</span><span class="tag-name">Window.Resources</span><span class="tag">></span><span> </span></li><li class="alt"><span> </span><span class="tag"><</span><span class="tag-name">Grid</span><span class="tag">></span><span> </span></li><li><span> </span><span class="tag"><</span><span class="tag-name">DataGrid</span><span> </span><span class="attribute">x:Name</span><span>=</span><span class="attribute-value">"dataGrid"</span><span> </span><span class="attribute">ItemsSource</span><span>=</span><span class="attribute-value">"{Binding}"</span><span> </span><span class="attribute">AutoGenerateColumns</span><span>=</span><span class="attribute-value">"False"</span><span class="tag">></span><span> </span></li><li class="alt"><span> </span><span class="tag"><</span><span class="tag-name">DataGrid.Columns</span><span class="tag">></span><span> </span></li><li><span> </span><span class="tag"><</span><span class="tag-name">DataGridTextColumn</span><span> </span><span class="attribute">Header</span><span>=</span><span class="attribute-value">"Name"</span><span> </span><span class="attribute">Width</span><span>=</span><span class="attribute-value">"80"</span><span> </span><span class="attribute">Binding</span><span>=</span><span class="attribute-value">"{Binding Name}"</span><span class="tag">/></span><span> </span></li><li class="alt"><span> </span><span class="tag"><</span><span class="tag-name">DataGridTextColumn</span><span> </span><span class="attribute">Header</span><span>=</span><span class="attribute-value">"Age"</span><span> </span><span class="attribute">Width</span><span>=</span><span class="attribute-value">"50"</span><span> </span><span class="attribute">Binding</span><span>=</span><span class="attribute-value">"{Binding Age}"</span><span class="tag">/></span><span> </span></li><li><span> </span><span class="tag"><</span><span class="tag-name">DataGridComboBoxColumn</span><span> </span><span class="attribute">Width</span><span>=</span><span class="attribute-value">"80"</span><span> </span><span class="attribute">Header</span><span>=</span><span class="attribute-value">"Sex"</span><span> </span></li><li class="alt"><span> </span><span class="attribute">SelectedItemBinding</span><span>=</span><span class="attribute-value">"{Binding Sex}"</span><span> </span></li><li><span> </span><span class="attribute">ItemsSource</span><span>=</span><span class="attribute-value">"{Binding Source={StaticResource sexEnum}}"</span><span class="tag">/></span><span> </span></li><li class="alt"><span> </span><span class="tag"><</span><span class="tag-name">DataGridCheckBoxColumn</span><span> </span><span class="attribute">Header</span><span>=</span><span class="attribute-value">"Pass Exam?"</span><span> </span><span class="attribute">Width</span><span>=</span><span class="attribute-value">"100"</span><span> </span></li><li><span> </span><span class="attribute">Binding</span><span>=</span><span class="attribute-value">"{Binding Pass}"</span><span class="tag">/></span><span> </span></li><li class="alt"><span> </span><span class="tag"><</span><span class="tag-name">DataGridHyperlinkColumn</span><span> </span><span class="attribute">Header</span><span>=</span><span class="attribute-value">"Email"</span><span> </span><span class="attribute">Width</span><span>=</span><span class="attribute-value">"150"</span><span> </span></li><li><span> </span><span class="attribute">Binding</span><span>=</span><span class="attribute-value">"{Binding Email}"</span><span class="tag">/></span><span> </span></li><li class="alt"><span> </span><span class="tag"></</span><span class="tag-name">DataGrid.Columns</span><span class="tag">></span><span> </span></li><li><span> </span><span class="tag"></</span><span class="tag-name">DataGrid</span><span class="tag">></span><span> </span></li><li class="alt"><span> </span><span class="tag"></</span><span class="tag-name">Grid</span><span class="tag">></span><span> </span></li><li><span class="tag"></</span><span class="tag-name">Window</span><span class="tag">></span><span> </span></li></ol> |
其中每列都包含各自的数值类型,在C# 中创建Member 类及SexOpt 枚举,并将memberData 数据绑定到DataGrid:
1 |
<ol class="dp-c"><li class="alt"><span><span class="keyword">using</span><span> System; </span></span></li><li><span class="keyword">using</span><span> System.Windows; </span></li><li class="alt"><span class="keyword">using</span><span> System.Collections.ObjectModel; </span></li><li><span> </span></li><li class="alt"><span class="keyword">namespace</span><span> WPF4ControlTest </span></li><li><span>{ </span></li><li class="alt"><span> </span><span class="comment">/// <summary> </span><span> </span></li><li><span> </span><span class="comment">/// Interaction logic for MainWindow.xaml </span><span> </span></li><li class="alt"><span> </span><span class="comment">/// </summary> </span><span> </span></li><li><span> </span><span class="keyword">public</span><span> partial </span><span class="keyword">class</span><span> MainWindow : Window </span></li><li class="alt"><span> { </span></li><li><span> </span><span class="keyword">public</span><span> MainWindow() </span></li><li class="alt"><span> { </span></li><li><span> InitializeComponent(); </span></li><li><span>ObservableCollection<Member> memberData = </span><span class="keyword">new</span><span> ObservableCollection<Member>(); </span></li><li><span> memberData.Add(</span><span class="keyword">new</span><span> Member() </span></li><li class="alt"><span> { </span></li><li><span> Name = </span><span class="string">"Joe"</span><span>, Age = </span><span class="string">"23"</span><span>, Sex = SexOpt.Male, </span></li><li class="alt"><span> Pass = </span><span class="keyword">true</span><span>, Email = </span><span class="keyword">new</span><span> Uri(</span><span class="string">"mailto:Joe@school.com"</span><span>) </span></li><li><span> }); </span></li><li class="alt"><span> memberData.Add(</span><span class="keyword">new</span><span> Member() </span></li><li><span> { </span></li><li class="alt"><span> Name = </span><span class="string">"Mike"</span><span>, Age = </span><span class="string">"20"</span><span>, </span></li><li><span> Sex = SexOpt.Male, Pass = </span><span class="keyword">false</span><span>, </span></li><li class="alt"><span> Email = </span><span class="keyword">new</span><span> Uri(</span><span class="string">"mailto:Mike@school.com"</span><span>) </span></li><li><span> }); </span></li><li class="alt"><span> memberData.Add(</span><span class="keyword">new</span><span> Member() </span></li><li><span> { </span></li><li class="alt"><span> Name = </span><span class="string">"Lucy"</span><span>, Age = </span><span class="string">"25"</span><span>, </span></li><li><span> Sex = SexOpt.Female, Pass = </span><span class="keyword">true</span><span>, </span></li><li class="alt"><span> Email = </span><span class="keyword">new</span><span> Uri(</span><span class="string">"mailto:Lucy@school.com"</span><span>) </span></li><li><span> }); </span></li><li class="alt"><span> dataGrid.DataContext = memberData; </span></li><li><span> } </span></li><li class="alt"><span> } </span></li><li><span> </span></li><li class="alt"><span> </span><span class="keyword">public</span><span> </span><span class="keyword">enum</span><span> SexOpt { Male, Female }; </span></li><li><span> </span></li><li class="alt"><span> </span><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> Member </span></li><li><span> { </span></li><li class="alt"><span> </span><span class="keyword">public</span><span> </span><span class="keyword">string</span><span> Name { </span><span class="keyword">get</span><span>; </span><span class="keyword">set</span><span>; } </span></li><li><span> </span><span class="keyword">public</span><span> </span><span class="keyword">string</span><span> Age { </span><span class="keyword">get</span><span>; </span><span class="keyword">set</span><span>; } </span></li><li class="alt"><span> </span><span class="keyword">public</span><span> SexOpt Sex { </span><span class="keyword">get</span><span>; </span><span class="keyword">set</span><span>; } </span></li><li><span> </span><span class="keyword">public</span><span> </span><span class="keyword">bool</span><span> Pass { </span><span class="keyword">get</span><span>; </span><span class="keyword">set</span><span>; } </span></li><li class="alt"><span> </span><span class="keyword">public</span><span> Uri Email { </span><span class="keyword">get</span><span>; </span><span class="keyword">set</span><span>; } </span></li><li><span> } </span></li><li class="alt"><span>} </span></li></ol> |
这样我们就可以通过自定义列的方式创建出DataGrid: 选择模式 默认情况下,DataGrid 的选择模式为“全行选择”,并且可以同时选择多行(如下图所示),我们可以通过SelectionMode 和SelectionUnit 属性来修改DataGrid 的选择模式。 SelectionUnit:包含Cell、FullRow 和CellOrRowHeader 三种单元选择模式。 ◆Cell:选择单元格; ◆FullRow:选择全行; ◆CellOrRowHeader:可选择单元格,也可以通过点击行首选择全行; SelectionMode:分为Extended 和Single 两种模式。 ◆Extended:选择多个单元(单元格或全行,由SelectionUnit 定义); ◆Single:选择唯一单元(单元格或全行,由SelectionUnit 定义);
1 |
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">DataGrid</span><span> </span><span class="attribute">x:Name</span><span>=</span><span class="attribute-value">"dataGrid"</span><span> </span><span class="attribute">ItemsSource</span><span>=</span><span class="attribute-value">"{Binding}"</span><span> </span><span class="attribute">AutoGenerateColumns</span><span>=</span><span class="attribute-value">"False"</span><span> </span></span></li><li><span> </span><span class="attribute">SelectionUnit</span><span>=</span><span class="attribute-value">"Cell"</span><span> </span><span class="attribute">SelectionMode</span><span>=</span><span class="attribute-value">"Extended"</span><span class="tag">></span><span>… … </span></li></ol> |
设置SelectionUnit 和SelectionMode 后的实例效果: 编辑 默认情况下,我们可以直接在DataGrid 中编辑数据(下表为相关的编辑命令),当然也可以通过IsReadOnly 属性将DataGrid 设置为只读方式。
1 |
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">DataGrid</span><span> </span><span class="attribute">x:Name</span><span>=</span><span class="attribute-value">"dataGrid"</span><span> </span><span class="attribute">ItemsSource</span><span>=</span><span class="attribute-value">"{Binding}"</span><span> </span><span class="attribute">AutoGenerateColumns</span><span>=</span><span class="attribute-value">"False"</span><span> </span></span></li><li><span> </span><span class="attribute">SelectionUnit</span><span>=</span><span class="attribute-value">"Cell"</span><span> </span><span class="attribute">SelectionMode</span><span>=</span><span class="attribute-value">"Extended"</span><span> </span><span class="attribute">IsReadOnly</span><span>=</span><span class="attribute-value">"True"</span><span class="tag">></span><span>… … </span></li></ol> |
原文标题:WPF 4 DataGrid 控件(基本功能篇) 链接:http://www.cnblogs.com/gnielee/archive/2010/04/16/wpf4-datagrid-control-basic.html
View Details1.获取所有数据库名: SELECT Name FROM Master..SysDatabases ORDER BY Name 2.获取所有表名: SELECT Name FROM DatabaseName..SysObjects Where XType=’U' ORDER BY Name XType=’U':表示所有用户表; XType=’S':表示所有系统表; 3.获取所有字段名: SELECT Name FROM SysColumns WHERE id=Object_Id('TableName') access : 如果表存在,如何得到这个表? SELECT * FROM MSysObjects where name=’ExamResultTime ' and type=1 and flags=0 //得到该数据库中所有的表名 SELECT name FROM MSysObjects where type=1 and flags=0 转自:http://www.soaspx.com/dotnet/sql/mssql/sql2000/sqlserver2000_20091215_2051.html
View Details