IEWebControl的toolbar的使用!!!!

偶然下载了IEWebControl的控件,因为原先知道treeview,对他的应用也略知一二,因为大家有太多的贴子讨论treeview.不过我今天来谈谈如何用toolbar控件,在这里介绍的也是toolbar的基本应用.

toolbar的应用主要是对ToolbarButton 、ToolbarCheckButton、ToolbarTextBox、ToolbarDropDownList等的定义,事件的处理。

下面是我对toobar研究的代码,主要环境是vs.net.

首先安装IEWebControl。

在vs.net的工具箱里,把toolbar控件加进去。这样你可以借助vs.net的可视化来设置toobar的一些属性了。

下面贴出代码供大家参考:

1..aspx文件

1@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="Excel.WebForm2" 
1@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
 1<html>
 2<head>
 3<title>WebForm2</title>
 4<meta content="Microsoft Visual Studio 7.0" name="GENERATOR"/>
 5<meta content="C#" name="CODE_LANGUAGE"/>
 6<meta content="JavaScript" name="vs_defaultClientScript"/>
 7<meta content=" http://schemas.microsoft.com/intellisense/ie5 " name="vs_targetSchema"/>
 8</head>
 9<body ms_positioning="GridLayout">
10<form id="WebForm2" method="post" runat="server">
11<font face="宋体">
12<iewc:toolbar font-size="X-Small" height="17px" id="Toolbar1" runat="server" style="Z-INDEX: 101; LEFT: 14px; POSITION: absolute; TOP: 61px" width="468px">
13<iewc:toolbarseparator></iewc:toolbarseparator>
14<iewc:toolbarbutton accesskey="f" id="Button1" text="文件(F)"></iewc:toolbarbutton>
15<iewc:toolbarseparator></iewc:toolbarseparator>
16<iewc:toolbarbutton accesskey="e" id="Button2" text="编辑(E)"></iewc:toolbarbutton>
17<iewc:toolbarseparator></iewc:toolbarseparator>
18<iewc:toolbarbutton accesskey="v" id="Button3" text="视图(V)"></iewc:toolbarbutton>
19<iewc:toolbarseparator></iewc:toolbarseparator>
20<iewc:toolbarbutton accesskey="p" id="Button4" text="项目(P)"></iewc:toolbarbutton>
21<iewc:toolbarseparator></iewc:toolbarseparator>
22<iewc:toolbarbutton accesskey="b" id="Button5" text="生成(B)"></iewc:toolbarbutton>
23<iewc:toolbarseparator></iewc:toolbarseparator>
24<iewc:toolbarbutton accesskey="d" id="Button6" text="调试(D)"></iewc:toolbarbutton>
25<iewc:toolbarseparator></iewc:toolbarseparator>
26<iewc:toolbarcheckbutton id="CheckButton1" text="boy"></iewc:toolbarcheckbutton>
27<iewc:toolbarseparator></iewc:toolbarseparator>
28<iewc:toolbartextbox id="TextBox1"></iewc:toolbartextbox>
29<iewc:toolbarseparator></iewc:toolbarseparator>
30<iewc:toolbardropdownlist autopostback="True" id="DropDownList1">
31<asp:listitem selected="True" value="1">1</asp:listitem>
32<asp:listitem value="2">2</asp:listitem>
33<asp:listitem value="3">3</asp:listitem>
34<asp:listitem value="4">4</asp:listitem>
35<asp:listitem value="5">5</asp:listitem>
36</iewc:toolbardropdownlist>
37<iewc:toolbarseparator></iewc:toolbarseparator>
38<iewc:toolbarlabel id="Label2"></iewc:toolbarlabel>
39<iewc:toolbarseparator></iewc:toolbarseparator>
40</iewc:toolbar>
41<asp:label height="37px" id="Label1" runat="server" style="Z-INDEX: 102; LEFT: 243px; POSITION: absolute; TOP: 219px" width="65px"></asp:label></font>
42</form>
43</body>
44</html>

2..cs文件
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.Web.UI.WebControls;

namespace Excel
{
///

1<summary>   
2/// WebForm2 的摘要说明。   
3/// </summary>

public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected Microsoft.Web.UI.WebControls.Toolbar Toolbar1;
protected Microsoft.Web.UI.WebControls.ToolbarDropDownList DropDownList1;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
ShowTime();
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

///

1<summary>   
2/// 设计器支持所需的方法 - 不要使用代码编辑器修改   
3/// 此方法的内容。   
4/// </summary>

private void InitializeComponent()
{
this.Toolbar1.ButtonClick += new System.EventHandler(this.Toolbar1_ButtonClick);
this.Load += new System.EventHandler(this.Page_Load);
this.DropDownList1.SelectedIndexChanged+=new System.EventHandler(this.DropDownList1_SelectedIndexChanged);

}
#endregion

private void Toolbar1_ButtonClick(object sender, System.EventArgs e)
{
ToolbarButton bt=new ToolbarButton();
bt=(ToolbarButton)sender;
switch(bt.ID)
{
case "Button1":
Label1.Text="Button1";
break;
case "Button2":
Label1.Text="Button2";
break;
case "Button3":
Label1.Text="Button3";
break;
case "Button4":
Label1.Text="Button4";
break;
case "Button5":
Label1.Text="Button5";
break;
case "Button6":
Label1.Text="Button6";
break;

}

}
private void DropDownList1_SelectedIndexChanged(object sender,System.EventArgs e)
{
DropDownList1=(ToolbarDropDownList)Toolbar1.Items[17];
Label1.Text=DropDownList1.SelectedItem.Text;
}
private void ShowTime()
{
ToolbarLabel Label2=new ToolbarLabel();
Label2=(ToolbarLabel)Toolbar1.Items[19];
Label2.Text=DateTime.Now.ToLongDateString();
}
}
}

1@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="Excel.WebForm2" 
2``` ```
3@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="Excel.WebForm2" 
4``` ```
5@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
6``` ```
7@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="Excel.WebForm2" 

@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Published At
Categories with Web编程
Tagged with
comments powered by Disqus