XP 风格的可拖动列、排序的DataGrid的例子






(CSS):
body
{
 background-color: buttonface;
 scroll: no;
 margin: 0px;
 border: none;
 overflow: hidden;
}

.xpTable
{
 behavior: url(xpTable.htc);
 sortNoneImageUrl: sortBlank.gif;
 sortUpImageUrl: sortUp.gif;
 sortDownImageUrl: sortDown.gif;
 posUpImageUrl: upArrow.gif;
 posDownImageUrl: downArrow.gif;
 position: relative;
    margin: 0px;
    width: 100%;
  font: menu;
 highlightBackgroundColor: #C1D2EE;
 highlightBorderColor: #316AC5;
 color: windowtext;
  cursor: default;
}
.xpTable THEAD TD
{
 border-left: 1px solid buttonhighlight;
 border-top: 1px solid buttonhighlight;
 border-bottom: 1px solid buttonshadow;
 border-right: 1px solid buttonshadow;
 font: menu;
 color: menutext;
 background-color: buttonface;
    cursor: hand;
    padding-top: 0px;
    padding-bottom: 1px;
}
.xpTable TBODY TR
{
 color: windowtext;
 background: window;
}


本文介绍XP 风格的可拖动列、排序的DataGrid的例子,请查看

要想使用本源代码,请先下载如下文件:

源代码如下:【C#版本】

DragableXpStyleTable.aspx

  <%@ Page language="c#" Codebehind="DragableXpStyleTable.aspx.cs" AutoEventWireup="false" Inherits="eMeng.Exam.DragableXpStyleTable.DragableXpStyleTable" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <META http-equiv="content-type" content="text/html; charset=gb2312"> <title>XP 风格的可拖动列、排序的DataGrid的例子</title> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"> <meta name="CODE_LANGUAGE" Content="C#"> rel="stylesheet" type="text/css" href="xpTable.css"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="DragableXpStyleTable" method="post" runat="server"> <div align="center" style="padding:20px"><b>XP 风格的可拖动列、排序的DataGrid的例子。</b></div> <asp:DataGrid id="xpTable" runat="server" AutoGenerateColumns="False" Cellpadding="2" BorderWidth="0" BorderStyle="None" STYLE="BORDER-COLLAPSE:separate" Width="90%" CssClass="xpTable"> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <Columns> <asp:BoundColumn ItemStyle-Height="22" DataField="Title" SortExpression="Title" HeaderText="文章标题" HeaderStyle-Font-Bold="True"></asp:BoundColumn> <asp:BoundColumn DataField="CreateDate" SortExpression="CreateDate" HeaderText="创建日期" HeaderStyle-Font-Bold="True" DataFormatString="{0:yyyy年MM月dd日 HH:mm:ss}"></asp:BoundColumn> <asp:BoundColumn DataField="SubTitle" SortExpression="SubTitle" HeaderText="所属栏目" HeaderStyle-Font-Bold="True"></asp:BoundColumn> </Columns> </asp:DataGrid> </form> </body> </HTML> 

DragableXpStyleTable.aspx.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 System.Data.OleDb; namespace eMeng.Exam.DragableXpStyleTable { /// <summary> /// DragableXpStyleTable 的摘要说明。 /// XP风格的可拖动的DataGrid /// </summary> public class DragableXpStyleTable : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid xpTable; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 xpTable.Attributes.Add("altRowColor","oldlace"); xpTable.Attributes.Add("align","center"); string cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="; cnString += System.Web.HttpContext.Current.Server.MapPath("TestTable.mdb") OleDbConnection cn = new OleDbConnection(cnString); cn.Open(); cnString = "SELECT TOP 15 D.Title,D.CreateDate,S.Title AS SubTitle "; cnString += "FROM Document D,Subject S WHERE D.pid=S.id ORDER BY D.CreateDate DESC"; OleDbCommand cmd = new OleDbCommand(cnString,cn); xpTable.DataSource=cmd.ExecuteReader(CommandBehavior.CloseConnection); xpTable.DataBind(); cmd.Dispose(); cn.Close(); cn.Dispose(); cn = null; } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } } 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值