这里有个例子,很详细:
在 Internet Explorer 中使用 Windows 窗体控件
http://chs.gotdotnet.com/quickstart/winforms/doc/WinFormsIeSourcing.aspx默认是VB的代码,要查看C#代码:
http://chs.gotdotnet.com/quickstart/winforms/
在右上角选择语言:C#
在左边选择:“Internet Explorer 中的控件”
在 Internet Explorer 中使用 Windows 窗体控件
http://chs.gotdotnet.com/quickstart/winforms/doc/WinFormsIeSourcing.aspx默认是VB的代码,要查看C#代码:
http://chs.gotdotnet.com/quickstart/winforms/
在右上角选择语言:C#
在左边选择:“Internet Explorer 中的控件”
解决方案 »
- 一个用c#调用c++写的dll里的函数的问题
- 关于弹出对话框确认执行代码的问题
- 听说.net里高手如云,想问问几百万数据处理的问题
- 哥,帮帮忙!关于导出excel问题
- MyGeneration的NHibernate脚本问题
- 可不可以给.net自带的类型和对象添加方法和属性,比如给string类型或String类加一个TrimMid(),那么我定义string x后可以直接使用x.TrimMid
- 被调用的控件居然捕捉不到mousedown事件???
- 请问如何将datagrid绑定到comboBox的选项中?
- 数据库的查询功能,出现怪现象
- 真的没人懂吗?想不到阿!
- 程序出错,大家帮我找找错在哪里???
- 高难问题! 如何在选中非模态对话框时主窗体依然保持 focus或者说如何让两个窗体同时focus
我参考的就是这个代码, windows用户控件显示不出来(我得用户控件中是个数型结构)
不知道是不是classid="http:winctrl1.dll#winctrl1.UserControl1" 有问题!
<object id="simpleControl1" classid="http:SimpleControl.dll#Microsoft.Samples.WinForms.Cs.SimpleControl.SimpleControl"
height="300" width="300" VIEWASTEXT>
<param name="Text" value="Simple Control">
</object>
这个例子是没有问题的。
windows窗体控件和windows用户控件有什么区别?VC#新建项目时,只有windows控件库这一项可以选择,我就是选择的这个写的.能不能举个例子
Almost any Windows Forms control could be, but for this example the SimpleControl that is included in the .NET Framework SDK QuickStart Tutorial Creating Controls will be used. 2. HTML Document : SimpleControl.html
The next step is to create an HTML document with and object tag to insert and activate the Windows Forms control. Some simple script and input tags will also be added to demonstrate programmatic access to the control.Object tag<object id="simpleControl1"
classid="http:SimpleControl.dll#Microsoft.Samples.WinForms.Cs.SimpleControl.SimpleControl"
height="300"
width="300">
<param name="Text" value="Simple Control">
</object> The classid has two interesting parts; the path to the control library and the fully qualified name of the control separated by the pound sign. If you are familiar with an ActiveX object tag, youll notice the lack of a GUID. In the case of Windows Forms, the combination of path and fully qualified classname serve as the unique identifier.Param tags are used to set properties on controls. The name attribute is the name of the property and the value attribute is the value of the property.Script<script>function ChangeText() {
simpleControl1.Text = text1.value;
}</script>--------------------------------------------------------------------------------<input type="text" id="text1">
<input type="button" value="Change Text" onclick="ChangeText()">
To gain programmatic access to your control, you can write script against it. A button and text box on the page is used in conjunction with the simple function ChangeText to set the text property of the control.Complete
The following is the complete HTML code for this example.
<html><script>function ChangeText() {
simpleControl1.Text = text1.value;
}</script><body> <p>Simple Control</p>
<br>
<br>
<object id="simpleControl1"
classid="http:SimpleControl.dll#Microsoft.Samples.WinForms.Cs.SimpleControl.SimpleControl"
height="300"
width="300">
<param name="Text" value="Simple Control">
</object>
<br>
<br>
<input type="text" id="text1">
<input type="button" value="Change Text" onclick="ChangeText()"></body></html>
Create a new virtual directory and populate it with both the control (SimpleControl.dll) and the HTML document (SimpleControl.html). Important: Set execution permissions on the virtual directory to scripts. The control will not be properly activated if the execution permissions are set to scripts & executables. 4. Configure Code Access Permissions
This sample will execute correctly if you are running the control from an intranet site and you have not altered the .Net Framework security policy. If you have altered policy, or if you are running the control from an internet site then you may need to configure Internet Explorer or alter security policy to allow it to run. One way to enable a specific site for control download and execution is to identify your hosting page as belonging to the Trusted zone. This change is done in Internet Explorer with the following steps. 1. Choose Tools|Options
2. Select the "Security" tab
3. Select the "Trusted Sites" icon
4. Click the Sites... button
5. Add your site using the dialog presented
6. Click OK to commit your changes Now, when you browse to that page, it should be in the Trusted Sites zone which has the Internet permission set by default. You can also configure the .net framework security policy to enable code to run from a particular web site or from the Internet. The SDK documentation contains details of how to configure security policy.
5. Run the Control
To run the control, just point Internet Explorer to SimpleControl.html in your virtual directory. If the control is not activating correctly it may be necessary to restart Internet Explorer or clear the assembly download cache.
SimpleControl.cs 新建选择:组件类
DrawingMode.cs 新建选择:类编译生成后,新建一个虚拟目录,将刚才的生成的.dll文件复制过去,然后按照例子中的方法添加一个.htm或者.aspx文件调用该控件。
我在simplecontrol中添加一个TreeView控件,编译后simpleControl.dll即使在windows应用界面中也显示不出来, 假设这种编译成的dll可以在web中使用,但如何让其中的TreeView控件显示??