.NET流水账

一个真正的开明进步的国家,不是一群奴才造成的,是要有独立个性,有自由思考的人造成的。

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  17 随笔 :: 0 文章 :: 30 评论 :: 6 引用

2007年9月26日 #

For Each MyItem As DataRowView In ComboBox1.Items
  MessageBox.Show(MyItem.Item("Name").ToString())
  If MyItem.Item("Name").ToString() = "A Name" Then
    ComboBox1.SelectedItem = MyItem
    ' Item found and selected, Exit the loop
    Exit For
  End If
Next
posted @ 2007-09-26 21:09 DalianGary 阅读(96) 评论(0) 编辑

2007年8月2日 #

    我们知道当使用C++, COM和ATL来开发ActiveX的时候得CAB文件里面的INF文件描述了如何注册以及复制到何处的指令。
但是当我们用C#来开发ActiveX的时候,INF文件里面Registerserver=Yes 不起作用。因为这个命令只是调用regsvr32 来注册相应的组件,他对C#开发的ActiveX不起作用。

1、为了发布C#开发的ActiveX我们首先在2005里面建立一个.NET的MSI文件,如下图所示:



在Setup的Added output file的属性窗口里面,确认将Register property 设置成vsdrpCOM, 这个设置确保了在安装的时候会
调用regasm 来注册ActiveX控件。

2、CAB文件的建立

1[version]
2signature="$CHICAGO$"
3AdvancedINF=2.0
4[Setup Hooks]
5hook1=hook1
6
7[hook1]
8run=msiexec.exe /i "%EXTRACT_DIR%\ActiveXDotDownload.msi" /qn




     注意,浏览器出于安全性考虑,会拦截未经数字认证的控件。修改浏览器设置,在Internet选项-〉安全-〉受信任的站点-〉站点 中添加服务器地址,不要选复选框“对该区域中的所有站点要求服务器验证”。解决浏览器拦截问题,而不用更改浏览器的安全级别。

结束语
本文探讨了使用C# 2.0 在。NET2005平台上面开发ActiveX的可行性,虽然和以往的一些技术手段来比,可能有些不足,但也不失
可以作为一种特殊情况下的手段。

 
 

posted @ 2007-08-02 10:17 DalianGary 阅读(2417) 评论(5) 编辑

2007年8月1日 #

在HTML中对.NET ActiveX的调用,与交互。
其实和普通的ActiveX调用方式没有太大不同,相信大家看了代码都明白。

 1<html>
 2    <head>
 3        <script language="javascript">
 4      function doScript()
 5       {
 6        myControl1.UserText = frm.txt.value;
 7        alert(myControl1.UserText);
 8       }

 9      
10
</script>
11</head>
12 <body color=white>
13  <hr>  
14      <font face=arial size=1>
15       <object id="myControl1" name="myControl1" classid="clsid:182AEEFE-A6D6-3014-A2FB-672AAB805E18"  codebase='DownloadActiveXNet.cab#version=1,0,0,0'>
16       </object>
17     </font>  
18     <form name="frm" id="frm">
19       <input type="text" name="txt" value="enter text here">
20       <input type=button value="Click me" onclick="doScript();">
21      
22      </form>
23  <hr>
24 </body>  
25
26</html>
27

运行后的效果如下图所示:
 

下一次再说说cab包的制作问题,即如何实现客户端下载安装的实现。
posted @ 2007-08-01 16:24 DalianGary 阅读(2771) 评论(6) 编辑

http://homer.cnblogs.com/archive/2005/01/04/86473.aspx中看到了一篇关于如何名叫“用C#编写ActiveX控件”的文章,受益匪浅。
但该文章可能是在旧版本的.NET开发环境中实现的,在.NET 2005怎么实现也没能成功实现,于是自己从头开始做了一个开发,几经周折终于实现,现在分享给大家。
1、ActiveX在.NET中的实现
 

如上图所示在.NET中使用UserControl来实现ActiveX。代码如下。
 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Drawing;
 5 using System.Data;
 6 using System.Text;
 7 using System.Windows.Forms;
 8 using System.Runtime.InteropServices;
 9 
10 // Add in these    using clauses for this example
11 using System.Reflection;
12 using Microsoft.Win32;
13 
14 
15 namespace ActiveXDotNet
16 {
17      //[ClassInterface(ClassInterfaceType.AutoDual)]
18     public partial class myControl : UserControl, AxMyControl
19     {
20         public myControl()
21         {
22             InitializeComponent();
23         }
24 
25         private String mStr_UserText;
26 
27         public String UserText
28         {          
29             get { return mStr_UserText + " OK"; }
30             set {
31                 mStr_UserText = value;
32                 this.txtUserText.Text = value;
33             }
34         }
35 
36         private void button1_Click(object sender, EventArgs e)
37         {
38             this.txtUserText.Text = "Hello World";
39         }
40 
41         private void button2_Click(object sender, EventArgs e)
42         {
43             InputForm frmInput = new InputForm();
44             frmInput.ShowDialog();
45         }
46 
47     }
48 }
49 

2、其中,将在HTML中使用的方法在接口AxMyControl中实现,代码如下:
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Text;
 4 
 5 namespace ActiveXDotNet
 6 {
 7     interface AxMyControl
 8     {
 9         String UserText { set; get; }
10     }
11 }
12 

3、Assembly.cs中的特殊设置:

1 // Setting ComVisible to false makes the types in this assembly not visible 
2 // to COM components.  If you need to access a type in this assembly from 
3 // COM, set the ComVisible attribute to true on that type.
4 [assembly: ComVisible(true)]

这样,一个简单的基于.NET的AticveX控件就开发完成了,下一次讲解具体的调用方法。
posted @ 2007-08-01 11:49 DalianGary 阅读(5333) 评论(10) 编辑

2006年3月30日 #

http://weblogs.asp.net/justin_rogers/articles/111146.aspx
posted @ 2006-03-30 12:56 DalianGary 阅读(77) 评论(0) 编辑

2005年12月5日 #

世界上最远的距离
不是生与死
而是我站在你的面前
你却不知道
我爱你

世界上最远的距离
不是我站在你的面前
你却不知道我爱你
而是明明知道彼此相爱
却不能在一起

世界上最远的距离,
不是知道彼此相爱,
却不能在一起,
而是明明无法抵挡这股思念,
却还得故意装作丝毫没把你放在心里

世界上最远的距离,
不是明明无法抵挡这股思念
却还得故意装作丝毫没把你放在心里
而是用一颗冷漠的心在你和爱你的人之间
掘了一条无法跨越的沟渠
posted @ 2005-12-05 09:26 DalianGary 阅读(204) 评论(3) 编辑

2005年10月13日 #

摘要: 1、DateTime 数字型 System.DateTime currentTime=new System.DateTime(); 1.1 取当前年月日时分秒 currentTime=System.DateTime.Now; 1.2 取当前年 int 年=currentTime.Year; 1.3 取当前月 int 月=currentTime.Month; 1.4 取当前日 int 日=curre...阅读全文
posted @ 2005-10-13 15:06 DalianGary 阅读(411) 评论(0) 编辑

摘要: 最近遇到了一个奇怪的现象,参见说明代码:1DimaAsString="1000"2DimbAsString="1"3DimcAsString="6"4DimdAsString5DimfAsLong67d=CStr(CLng(a)*CLng(b)/CLng(c))8f=(CLng(a)*CLng(b)/CLng(c)).ToString910MessageBox.Show(d)11MessageBo...阅读全文
posted @ 2005-10-13 10:54 DalianGary 阅读(3423) 评论(3) 编辑

2005年10月12日 #

摘要: MS SQLSERVER 只能得到存储过程的创建语句,方法如下:sp_helptext procedureName但是往往我们需要得到表的创建语句,比如说在数据库升级的时候判断某个表是否已经改变,或者已经有一个表存在,但不知道它的创建语句是什么,字段有没有约束,有没有主键,创建了哪些索引等等.下面我给出一个存储过程,供读者参考.该存储过程可以得到你想得到的所有的表的创建语句,包括和表有关的索引的创...阅读全文
posted @ 2005-10-12 15:16 DalianGary 阅读(548) 评论(1) 编辑

摘要: 1ifexists(select*fromsysobjectswhereid=2object_id('spu_GenerateInsert'))3dropprocedurespu_GenerateInsert4GO567CREATEPROCEDUREspu_GenerateInsert8@tablevarchar(128)9AS102627--declaresomevariablesthatwil...阅读全文
posted @ 2005-10-12 14:45 DalianGary 阅读(836) 评论(1) 编辑