显示标签为“dotnet”的博文。显示所有博文
显示标签为“dotnet”的博文。显示所有博文

星期一, 七月 16, 2007

.NET Google Data API SDK setup program released - Google Labs - Code Search | Google 网上论坛 - 使用 Google 工具栏进行发送

.NET Google Data API SDK setup program released - Google Labs - Code Search | Google 网上论坛

In parallel to the usual .zip file delivery for our Mono users, we are now
going to release the .NET SDK as a .msi self-installable setup program as
well.

The setup installs the assemblies in the GAC, as well as having a directory
for re-distributable components. It contains the documentation and all
sample programs. We hope that this will make it easier to get into the world
of .NET programming with the Google Data APIs.

You can find the setup:

http://code.google.com/p/google-gdata/downloads/list

Please let us know what you think, and we hope you enjoy it.

Regards

Frank Mantek
Google


......


详细内容...

星期三, 七月 04, 2007

.Net开发人员应该下载的十种必备工具 - .Net - - 程序设计 - ZDNetChina中文社区 资讯|硬件|软件|开发|技术论坛 - 使用 Google 工具栏进行发送

.Net开发人员应该下载的十种必备工具 - .Net - - 程序设计 - ZDNetChina中文社区 资讯|硬件|软件|开发|技术论坛

.Net开发人员应该下载的十种必备工具

・用于编写单元测试的 NUnit
・用于创建代码文档资料的 NDoc
・用于生成解决方案的 NAnt
・用于生成代码的 CodeSmith
・用于监视代码的 FxCop
・用于编译少量代码的 Snippet Compiler
   
  
  
   
・两种不同的转换器工具:ASP.NET 版本转换器和 Visual Studio .NET 项目转换器
・用于生成正则表达式的 Regulator
・用于分析程序集的 .NET Reflector

......


详细内容...

星期五, 六月 29, 2007

关于WINFORM中输入法的设置 - johnsuna(阿山NET)的专栏 - CSDNBlog - 已使用 Google 工具栏发送

关于WINFORM中输入法的设置 - johnsuna(阿山NET)的专栏 - CSDNBlog


关于WINFORM中输入法的设置

在WINFORM中我们经常遇到文本输入框中输入法被禁用或老是变全角输入法等问题,经查阅相关资料,现小结如下:

(一)Control.ImeMode 属性:获取或设置控件的输入法编辑器 (IME) 模式。 
(1)由于窗体属性继承关系,如果你的WINFORM窗体中大部分需要设置为输入法有效状态,可以设置为FORM的ImeMode属性为On.
(2)如果需要某些TextBox为输入法有效,则使用ImeMode.On
(3)如果需要设置整个窗体的输入法全部为半角,可以使用以下代码:
 #region 修正输入法全角/半角的问题
        //声明一些API函数  
        [DllImport("imm32.dll")]
        public static extern IntPtr ImmGetContext(IntPtr hwnd);
        [DllImport("imm32.dll")]
        public static extern bool ImmGetOpenStatus(IntPtr himc);
        [DllImport("imm32.dll")]
        public static extern bool ImmSetOpenStatus(IntPtr himc, bool b);
        [DllImport("imm32.dll")]
        public static extern bool ImmGetConversionStatus(IntPtr himc, ref   int lpdw, ref   int lpdw2);
        [DllImport("imm32.dll")]
        public static extern int ImmSimulateHotKey(IntPtr hwnd, int lngHotkey);
        private const int IME_CMODE_FULLSHAPE = 0x8;
        private const int IME_CHOTKEY_SHAPE_TOGGLE = 0x11;
        protected override void OnActivated(EventArgs e)
        {
            base.OnActivated(e);
            IntPtr HIme = ImmGetContext(this.Handle);    
            //如果输入法处于打开状态 
            if (ImmGetOpenStatus(HIme))
            {
                int iMode = 0;
                int iSentence = 0;
                //检索输入法信息  
                bool bSuccess = ImmGetConversionStatus(HIme, ref   iMode, ref   iSentence);    
                if (bSuccess)
                {
                    //如果是全角,转换成半角 
                    if ((iMode & IME_CMODE_FULLSHAPE) > 0)       
                        ImmSimulateHotKey(this.Handle, IME_CHOTKEY_SHAPE_TOGGLE);       
                }

            }
        }
       
......


详细内容...

星期二, 六月 12, 2007

Visual C++ 2005配置安装

MS即将发布的Visual Studio 2005在04年6月发布了一个stable的beta版本供大家免费测试,官方下载地址如下:
http://lab.msdn.microsoft.com/vs2005/
下载前需填写一个online form,你也可以从以下网址中找到直接下载链接,但我没有验证过是否这是一个较早的版本:
http://blog.joycode.com/uestc95/archive/2004/07/01/26234.aspx
这里还有一个2004.10的版本的下载链接(Express Team发布):
http://blogs.msdn.com/express/archive/2004/10/21/246091.aspx
或者你还可以从下面的链接中找到更新的beta 2(2005.2)的下载链接,但该版本好像必须在线安装:
http://lab.msdn.microsoft.com/vs2005/downloads/default.aspx
目前尚未在MS的官方消息中找到该beta版本的expiration的说明,故应该可以无限期使用,跟Visual Studio Toolkit
2003一样。不过跟2003不同的是,2003只是一个编译器,而此次发布的2005
express则是一个比较完整的IDE。说它比较完整,是因为它没有提供MFC/ATL等支持,并且还没有提供资源编辑器。

介绍完毕,下面是安装步骤:
1、安装Visual C++ 2005 express前需安装.net framework 2.0 beta:
http://download.microsoft.com/download/2/d/9/2d96a8eb-a612-46ad-b4ed-6497a8e1f245/dotnetfx.exe
2、安装Visual C++ 2005 express,完成安装后你可以休息一会儿,打开Visual C++ 2005欣赏一下;然后,还有很多事情要做...
3、安装Platform SDK:
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
强烈建议将PSDK安装包下载到本地后进行安装,下载完毕后拔掉网线,然后关闭病毒防火墙进行安装,这样速度应该会快很多,否则,安装过程可能需要好1个小时甚至更多。
安装完毕后,你需要修改VC++2005的环境配置:
Tools->Options->Projects and Solutions->VC++ Directories
Executable files - C:\Program Files\Microsoft SDK\Bin
Include files - C:\Program Files\Microsoft SDK\include
Library files - C:\Program Files\Microsoft SDK\lib
4、此时,你应该可以编译一些最简单的Hello world程序了,但只要你使用任何Win32
API,你都可能会遇到一大堆的链接错误,我曾经为这个问题苦恼了好几天,在好几个论坛上发布了好些帖子也没有人回答,终于,有一天,我在下面的链接中找到了答案
http://lab.msdn.microsoft.com/express/visualc/usingpsdk/default.aspx
你只需修改一下Visual C++安装目录下的文件corewin_express.vsprops(在D:\Program
Files\Microsoft Visual Studio
8\VC\VCProjectDefaults下,假定你的VC2005装在D:\Program Files下),这是一个XML文件,将其中的
AdditionalDependencies="kernel32.lib"
改成
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"
即可,注意,不要删掉了节点AdditionalDependencies后的 />
OK,免费的VC2005准备就绪了!Let''''s go!
......


详细内容...

C# 开发和使用中的23个技巧 , C#,开发,使用,23,技巧, , - CSDN 新闻 - 使用 Google 工具栏进行发送

 1.怎样定制VC#DataGrid列标题?

  DataGridTableStyle dgts = new DataGridTableStyle();

  dgts.MappingName = "myTable"; //myTable为要载入数据的DataTable

  

  DataGridTextBoxColumn dgcs = new DataGridTextBoxColumn();

  dgcs.MappingName = "title_id";

  dgcs.HeaderText = "标题ID";

  dgts.GridColumnStyles.Add(dgcs);

  。。。

  dataGrid1.TableStyles.Add(dgts);

  2.检索某个字段为空的所有记录的条件语句怎么写?

  ...where col_name is null

  3.如何在c# Winform应用中接收回车键输入?

  设一下form的AcceptButton.

  4.比如Oracle中的NUMBER(15),在Sql Server中应是什么?

  NUMBER(15):用numeric,精度15试试。

  5.sql server的应用like语句的存储过程怎样写?

  select * from mytable where haoma like '%' + @hao + '%'

  6.vc# winform中如何让textBox接受回车键消息(假没没有按钮的情况下)?

  private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)

  {

  if(e.KeyChar != (char)13)

  return;

  else

  //do something;

  }

  7.为什么(Int32)cmd.ExecuteScalar()赋值给Int32变量时提示转换无效?

  Int32.Parse(cmd.ExecuteScalar().ToString());

  8.DataSource为子表的DataGrid里怎样增加一个列以显示母表中的某个字段?

  在子表里手动添加一个列。

  DataColumn dc = new DataColumn("newCol", Type.GetType("System.String"));

  dc.Expression = "Parent.parentColumnName";

  dt.Columns.Add(dc); //dt为子表

  9.怎样使DataGrid显示DataTable中某列的数据时只显示某一部分?

  select ..., SUBSTR(string, start_index, end_index) as ***, *** from ***

  10.如何让winform的combobox只能选不能输入?

  DropDownStyle 属性确定用户能否在文本部分中输入新值以及列表部分是否总显示。

  值:

  DropDown --- 文本部分可编辑。用户必须单击箭头按钮来显示列表部分。

  DropDownList --- 用户不能直接编辑文本部分。用户必须单击箭头按钮来显示列表部分。

  Simple --- 文本部分可编辑。列表部分总可见。

  11.怎样使winform的DataGrid里显示的日期只显示年月日部分,去掉时间?

  sql语句里加上to_date(日期字段,'yyyy-mm-dd')

  12.怎样把 数据库表的二个列合并成一个列Fill进DataSet里?

  dcChehao = new DataColumn("newColumnName", typeof(string));

  dcChehao.Expression = "columnName1+columnName2";

  dt.Columns.Add(dcChehao);

  Oracle:

  select col1||col2 from table

  sql server:

  select col1+col2 from table

  13.如何从合并后的字段里提取出括号内的文字作为DataGrid或其它绑定控件的显示内容?即把合并后的字段内容里的左括号(和右括号)之间的文字提取出来。

  Select COL1,COL2, case

  when COL3 like '%(%' THEN substr(COL3, INSTR(COL3, '(' )+1, INSTR(COL3,')')-INSTR(COL3,'(')-1)

  end as COL3

  from MY_TABLE

  14.当用鼠标滚轮浏览DataGrid数据超过一定范围DataGrid会失去焦点。怎样解决?

  this.dataGrid1.MouseWheel+=new MouseEventHandler(dataGrid1_MouseWheel);

  private void dataGrid1_MouseWheel(object sender, MouseEventArgs e)

  {

  this.dataGrid1.Select();

  }

  15.怎样把键盘输入的'+'符号变成'A'?

  textBox的KeyPress事件中

  if(e.KeyChar == '+')

  {

  SendKeys.Send("A");

  e.Handled = true;

  }

  16.怎样使Winform启动时直接最大化?

  this.WindowState = FormWindowState.Maximized;

  17.c#怎样获取当前日期及时间,在sql语句里又是什么?

  c#: DateTime.Now

  sql server: GetDate()

  18.怎样访问winform DataGrid的某一行某一列,或每一行每一列?

  dataGrid[row,col]

  19.怎样为DataTable进行汇总,比如DataTable的某列值'延吉'的列为多少?

  dt.Select("城市='延吉'").Length;

  20.DataGrid数据导出到Excel后0212等会变成212。怎样使它导出后继续显示为0212?

  range.NumberFormat = "0000";

  21.

  ① 怎样把DataGrid的数据导出到Excel以供打印?

  ② 之前已经为DataGrid设置了TableStyle,即自定义了列标题和要显示的列,如果想以自定义的视图导出数据该怎么办?

  ③ 把数据导出到Excel后,怎样为它设置边框啊?

  ④ 怎样使从DataGrid导出到Excel的某个列居中对齐?

  ⑤ 数据从DataGrid导出到Excel后,怎样使标题行在打印时出现在每一页?

  ⑥ DataGrid数据导出到Excel后打印时每一页显示'当前页/共几页',怎样实现?

  ①

  private void button1_Click(object sender, System.EventArgs e)

  {

  int row_index, col_index;

  

  row_index = 1;

  col_index = 1;

  

  Excel.ApplicationClass excel = new Excel.ApplicationClass();

  excel.Workbooks.Add(true);

  

  DataTable dt = ds.Tables["table"];

  

  foreach(DataColumn dcHeader in dt.Columns)

  excel.Cells[row_index, col_index++] = dcHeader.ColumnName;

  

  foreach(DataRow dr in dt.Rows)

  {

  col_index = 0;

  foreach(DataColumn dc in dt.Columns)

  {

  excel.Cells[row_index+1, col_index+1] = dr[dc];

  col_index++;

  }

  row_index++;

  }

  excel.Visible = true;

  

  }

  

  private void Form1_Load(object sender, System.EventArgs e)

  {

  SqlConnection conn = new SqlConnection("server=tao;uid=sa;pwd=;database=pubs");

  conn.Open();

  

  SqlDataAdapter da = new SqlDataAdapter("select * from authors", conn);

  ds = new DataSet();

  da.Fill(ds, "table");

  

  dataGrid1.DataSource = ds;

  dataGrid1.DataMember = "table";

  }

  ②dataGrid1.TableStyles[0].GridColumnStyles[index].HeaderText;//index可以从0~dataGrid1.TableStyles[0].GridColumnStyles.Count遍历。

  ③ Excel.Range range;

  range=worksheet.get_Range(worksheet.Cells[1,1],xSt.Cells[ds.Tables[0].Rows.Count+1,ds.Tables[0].Columns.Count]);

  

  range.BorderAround(Excel.XlLineStyle.xlContinuous,Excel.XlBorderWeight.xlThin,Excel.XlColorIndex.xlColorIndexAutomatic,null);

  

  range.Borders[Excel.XlBordersIndex.xlInsideHorizontal].ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;

  range.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle =Excel.XlLineStyle.xlContinuous;

  range.Borders[Excel.XlBordersIndex.xlInsideHorizontal].Weight =Excel.XlBorderWeight.xlThin;

  

  range.Borders[Excel.XlBordersIndex.xlInsideVertical].ColorIndex =Excel.XlColorIndex.xlColorIndexAutomatic;

  range.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = Excel.XlLineStyle.xlContinuous;

  range.Borders[Excel.XlBordersIndex.xlInsideVertical].Weight = Excel.XlBorderWeight.xlThin;

  ④ range.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter

  ⑤ worksheet.PageSetup.PrintTitleRows = "$1:$1";

  ⑥ worksheet.PageSetup.CenterFooter = "第&P页 / 共&N页";

  22.当把DataGrid的Cell内容赋值到Excel的过程中想在DataGrid的CaptionText上显示进度,但不显示。WHY?

  ...

  dataGrid1.CaptionText = "正在导出:" + (row + 1) + "/" + row_cnt;

  System.Windows.Forms.Application.DoEvents();

  ...

  

  处理当前在消息队列中的所有Windows消息。

  

  当运行Windows窗体时,它将创建新窗体,然后该窗体等待处理事件。该窗体在每次处理事件时,均将处理与该事件关联的所有代码。所有其他事件在队列中等待。在代码处理事件时,应用程序并不响应。如果在代码中调用DoEvents,则应用程序可以处理其他事件。

  如果从代码中移除DoEvents,那么在按钮的单机事件处理程序执行结束以前,窗体不会重新绘制。通常在循环中使用该方法来处理消息。

  23.怎样从Flash调用外部程序,如一个C#编译后生成的.exe?

  fscommand("exec", "应用程序.exe");

  ① 必须把flash发布为.exe

  ② 必须在flash生成的.exe文件所在目录建一个名为fscommand的子目录,并把要调用的可执行程序拷贝到那里。

  24.有没有办法用代码控制DataGrid的上下、左右的滚动?

  dataGrid1.Select();

  SendKeys.Send("{PGUP}");

  SendKeys.Send("{PGDN}");

  SendKeys.Send("{^{LEFT}"); // Ctrl+左方向键

  SendKeys.Send("{^{RIGHT}"); // Ctrl+右方向键

  25.怎样使两个DataGrid绑定两个主从关系的表?

  DataGrid1.DataSource = ds;

  DataGrid1.DataMember = "母表";

  ...

  DataGrid2.DataSouce = ds;

  DataGrid2.DataMember = "母表.关系名";

  26.assembly的版本号怎样才能自动生成?特别是在Console下没有通过VStudio环境编写程序时。

  关键是AssemblyInfo.cs里的[assembly: AssemblyVersion("1.0.*")],命令行编译时包含AssemblyInfo.cs

  27.怎样建立一个Shared Assembly?

  用sn.exe生成一个Strong Name:keyfile.sn,放在源程序目录下

  在项目的AssemblyInfo.cs里[assembly: AssemblyKeyFile("..\\..\\keyfile.sn")]

  生成dll后,用gacutil /i myDll.dll放进Global Assembly Cach.

  28.在Oracle里如何取得某字段第一个字母为大写英文A~Z之间的记录?

  select * from table where ascii(substr(字段,1,1)) between ascii('A') and ascii('Z')

  29.怎样取得当前Assembly的版本号?

  Process current = Process.GetCurrentProcess();

  FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(current.MainModule.FileName);

  Console.WriteLine(myFileVersionInfo.FileVersion);

  30.怎样制作一个简单的winform安装程序?

  ① 建一个WinForm应用程序,最最简单的那种。运行。

  ② 添加新项目->安装和部署项目,'模板'选择'安装向导'。

  ③ 连续二个'下一步',在'选择包括的项目输出'步骤打勾'主输出来自',连续两个'下一步','完成'。

  ④ 生成。

  ⑤ 到项目目录下找到Setup.exe(还有一个.msi和.ini文件),执行。

  31.怎样通过winform安装程序在Sql Server数据库上建表?

  ① [项目]―[添加新项]

  类别:代码;模板:安装程序类。

  名称:MyInstaller.cs

  ② 在SQL Server建立一个表,再[所有任务]―[生成SQL脚本]。

  生成类似如下脚本(注意:把所有GO语句去掉):

  if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MyTable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

  drop table [dbo].[MyTable]

  

  CREATE TABLE [dbo].[MyTable] (

  [ID] [int] NOT NULL ,

  [NAME] [nchar] (4) COLLATE Chinese_PRC_CI_AS NOT NULL

  ) ON [PRIMARY]

  

  

  ALTER TABLE [dbo].[MyTable] WITH NOCHECK ADD

  CONSTRAINT [PK_MyTable] PRIMARY KEY CLUSTERED

  (

  [ID]

  ) ON [PRIMARY]

  ③ [项目]―[添加现有项]。mytable.sql―[生成操作]-[嵌入的资源]。

  ④ 将MyInstaller.cs切换到代码视图,添加下列代码:

  先增加:

  using System.Reflection;

  using System.IO;

  然后:

  private string GetSql(string Name)

  {

  try

  {

    Assembly Asm = Assembly.GetExecutingAssembly();

    Stream strm = Asm.GetManifestResourceStream(Asm.GetName().Name + "." + Name);

    StreamReader reader = new StreamReader(strm);

    return reader.ReadToEnd();

  }

  catch (Exception ex)

  {

    Console.Write("In GetSql:"+ex.Message);

    throw ex;

  }

  }

  

  private void ExecuteSql(string DataBaseName,string Sql)

  {

  System.Data.SqlClient.SqlConnection sqlConn = new System.Data.SqlClient.SqlConnection();

  sqlConn.ConnectionString = "server=myserver;uid=sa;password=;database=master";

  System.Data.SqlClient.SqlCommand Command = new System.Data.SqlClient.SqlCommand(Sql,sqlConn);

  

  Command.Connection.Open();

  Command.Connection.ChangeDatabase(DataBaseName);

  try

  {

  Command.ExecuteNonQuery();

  }

  finally

  {

  Command.Connection.Close();

  }

  }

  protected void AddDBTable(string strDBName)

  {

  try

  {

  ExecuteSql("master","create DATABASE "+ strDBName);

  ExecuteSql(strDBName,GetSql("mytable.sql"));

  }

  catch(Exception ex)

  {

  Console.Write("In exception handler :"+ex.Message);

  }

  }

  

  public override void Install(System.Collections.IDictionary stateSaver)

  {

  base.Install(stateSaver);

  AddDBTable("MyDB"); //建一个名为MyDB的DataBase

  }

  ⑤ [添加新项目]―[项目类型:安装和部署项目]―[模板:安装项目]―[名称:MySetup]。

  ⑥ [应用程序文件夹]―[添加]―[项目输出]―[主输出]。

  ⑦ 解决方案资源管理器―右键―[安装项目(MySetup)]―[视图]―[自定义操作]。[安装]―[添加自定义操作]―[双击:应用程序文件夹]的[主输出来自***(活动)]。

  32.怎样用TreeView显示父子关系的数据库表(winform)?

  三个表a1,a2,a3, a1为a2看母表,a2为a3的母表。

  a1: id, name

  a2: id, parent_id, name

  a3: id, parent_id, name

  用三个DataAdapter把三个表各自Fill进DataSet的三个表。

  用DataRelation设置好三个表之间的关系。

  

  foreach(DataRow drA1 in ds.Tables["a1"].Rows)

  {

   tn1 = new TreeNode(drA1["name"].ToString());

   treeView1.Nodes.Add(tn1);

   foreach(DataRow drA2 in drA1.GetChildRows("a1a2"))

   {

  tn2 = new TreeNode(drA2["name"].ToString());

  tn1.Nodes.Add(tn2);

  foreach(DataRow drA3 in drA2.GetChildRows("a2a3"))

  {

   tn3 = new TreeNode(drA3["name"].ToString());

   tn2.Nodes.Add(tn3);

  }

   }

  }

  33.怎样从一个form传递数据到另一个form?

  假设Form2的数据要传到Form1的TextBox。

  在Form2:

  // Define delegate

  public delegate void SendData(object sender);

  // Create instance

  public SendData sendData;

  在Form2的按钮单击事件或其它事件代码中:

  if(sendData != null)

  {

   sendData(txtBoxAtForm2);

  }

  this.Close(); //关闭Form2

  在Form1的弹出Form2的代码中:

  Form2 form2 = new Form2();

  form2.sendData = new Form2.SendData(MyFunction);

  form2.ShowDialog();

  ====================

  private void MyFunction(object sender)

  {

  textBox1.Text = ((TextBox)sender).Text;

  }

  


......


详细内容...

星期四, 一月 25, 2007

C#操作Word文档(Office 2007)

首先引入类库,Microsoft.Office.Interop.Word,然后进行编程。代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.Word;

namespace WordTest
{
public partial class Form1 : Form
{
object strFileName;
Object Nothing;
Microsoft.Office.Interop.Word.Application myWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
Document myWordDoc;
string strContent = "";

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
createWord();
//openWord();
}

private void createWord()
{
strFileName = System.Windows.Forms.Application.StartupPath + "test.doc";
if (System.IO.File.Exists((string)strFileName))
System.IO.File.Delete((string)strFileName);
Object Nothing = System.Reflection.Missing.Value;
myWordDoc = myWordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);

#region 将数据库中读取得数据写入到word文件中

strContent = "你好\n\n\r";
myWordDoc.Paragraphs.Last.Range.Text = strContent;

strContent = "这是测试程序";
myWordDoc.Paragraphs.Last.Range.Text = strContent;


#endregion

//将WordDoc文档对象的内容保存为DOC文档
myWordDoc.SaveAs(ref strFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//关闭WordDoc文档对象
myWordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
//关闭WordApp组件对象
myWordApp.Quit(ref Nothing, ref Nothing, ref Nothing);

this.richTextBox1.Text = strFileName + "\r\n" + "创建成功";

}
private void openWord()
{
fontDialog1.ShowDialog();
System.Drawing.Font font = fontDialog1.Font;
object filepath = "D:\\asp.docx";
object oMissing = System.Reflection.Missing.Value;
myWordDoc = myWordApp.Documents.Open(ref filepath, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
myWordDoc.Content.Font.Size = font.Size;
myWordDoc.Content.Font.Name = font.Name;
myWordDoc.Save();
richTextBox1.Text = myWordDoc.Content.Text;


myWordDoc.Close(ref oMissing, ref oMissing, ref oMissing);
myWordApp.Quit(ref oMissing, ref oMissing, ref oMissing);
}

}
......


详细内容...

ASP.NET热点问题解答

   1、ASP.NET能在那些系统中运行?
  目前,ASP.NET还只能奔跑在微软的Windows 2000、Windows XP和Windows 2003的系统中,并且需要微软Internet Information Server(IIS)的支持,微软原计划要让Windows NT4.0也支持ASP.NET,但可能微软是有些技术问题或市场考虑,还没有实现NT下的ASP.NET的支持。
  2、在一个ASPX文件中是否可以使用一种以上的语言?
  答案让你有点失望,虽然微软的提供了公共语言运行环境(CLR,Common Laguage Runtime),实现了多种编程语言间的紧密集成,可以允许你从一个VB对象中导出C#所需的对象来,但一个ASPX文件中只能用一种语言,正如你不能在VB.NET中使用C#的语法一样。
  3、ASPX文件的服务器端脚本支持那些语言?
  目前,ASPX文件只支持C#、Visual Basic.NET、Jscript.NET和J#,但是你使用code—behind(代码分离)的方法创建一个独立代码文件,你就可以使用任何.NET编译器支持的语言来实现功能了。
  4、在Global.asax文件中能使用code—behind(代码分离)技术吗?
5、我能否看到ASPX文件在ASP.NET中生成的代码吗?
  可以看到的,当你的ASPX文件中包含命令或Web.config中声明了时,你就可以在系统目录下的Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP.NET Files中找到ASPX文件在ASP.NET下生成的文件。
  6、在ASPX文件中如何注释呢?
  同ASP文件中的方法一样。
  7、ASPX文件中是否可以存在一个以上服务器端 Form 标记?
  不可以
  8、我可以在Web窗体中使用自定义数据类型吗
  可以,你可以把包含自定义数据类型的DLL文件放在程序根目录下的BIN目录中,ASP.NET会在数据类型引用时,装载DLL文件的。
  9、我能在Global.asax文件中触发那些事件?
10、Web控件是否支持样式表(CSS)呢?
  Yes. All Web controls inherit a property named CssClass from the base class System.Web.UI.WebControls.WebControl. The following example defines a CSS class named Input and uses it to modify a TextBox control to display text in red 10-point Verdana type:
  支持,所有的Web控件都从基类System.Web.UI.WebControls.WebControl中继承了一个叫做CssClass的属性。
  例如:

   11、在ASPX文件中默认导入那些名称空间?

  ASPX默认导入的名称空间可以直接引用了,使用其它的名称空间就的自行导入了。

  默认名称空间
   System
   System.Collections
   System.Collections.Specialized
   System.Configuration
   System.Text
   System.Text.RegularExpressions
   System.Web
   System.Web.Caching
   System.Web.Security
   System.Web.SessionState
   System.Web.UI
   System.Web.UI.HtmlControls
   System.Web.UI.WebControls
  12、我是否可以自己创建服务器控件呢?

  可以,创作您自己的 ASP.NET 服务器控件很容易。创建简单的自定义控件时,您所要做的只是定义从 System.Web.UI.Control 派生的类并重写它的 Render 方法。Render 方法采用 System.Web.UI.HtmlTextWriter 类型的参数。控件要发送到客户端的 HTML 作为字符串参数传递到 HtmlTextWriter 的 Write 方法。

  13、如何在ASP.NET程序中发送邮件呢?

  在ASP.NET程序中发送邮件不再象ASP中那样需要组件的支持了,在.NET的框架基类的System.Web.Mail名称空间内包含的MailMessage和SmtpMail类可以实现这个功能。
  例如:
  Dim message As new Mail.MailMessage
  message.From = "web3@163.com"
  message.To = "web3@163.com"
  message.Subject = "测试"
  message.Body = "内容"
  Mail.SmtpMail.SmtpServer = "localhost"
  Mail.SmtpMail.Send(message)
......


详细内容...