实现如何调整DataGrid列宽

DragDataGrid.JPG
1.html

None.gif < HTML >
None.gif    
< HEAD >
None.gif        
< title > DragDataGrid </ title >
None.gif        
< meta  name ="GENERATOR"  Content ="Microsoft Visual Studio .NET 7.1" >
None.gif        
< meta  name ="CODE_LANGUAGE"  Content ="C#" >
None.gif        
< meta  name ="vs_defaultClientScript"  content ="JavaScript" >
None.gif        
< meta  name ="vs_targetSchema"  content ="http://schemas.microsoft.com/intellisense/ie5" >
None.gif        
< LINK  href ="xpTable.css"  type ="text/css"  rel ="stylesheet" >
None.gif    
</ HEAD >
None.gif    
< body  ms_positioning ="GridLayout" >
None.gif        
< form  id ="Form1"  method ="post"  runat ="server" >
None.gif            
< asp:DataGrid  id ="DataGrid1"  runat ="server"  Font-Size ="9pt"  CellPadding ="4"  style ="BEHAVIOR:url(draggrid.htc)"
None.gif                BorderColor
="#CC9966"  BorderStyle ="None"  BorderWidth ="1px"  BackColor ="White" >
None.gif                
< SelectedItemStyle  Font-Bold ="True"  ForeColor ="#663399"  BackColor ="#FFCC66" ></ SelectedItemStyle >
None.gif                
< ItemStyle  ForeColor ="#330099"  BackColor ="White" ></ ItemStyle >
None.gif                
< HeaderStyle  Font-Bold ="True"  ForeColor ="#FFFFCC"  BackColor ="#990000" ></ HeaderStyle >
None.gif                
< FooterStyle  ForeColor ="#330099"  BackColor ="#FFFFCC" ></ FooterStyle >
None.gif                
< PagerStyle  HorizontalAlign ="Center"  ForeColor ="#330099"  BackColor ="#FFFFCC" ></ PagerStyle >
None.gif            
</ asp:DataGrid > &nbsp;
None.gif        
</ form >
None.gif    
</ body >
None.gif
</ HTML >
2.cs
None.gif public   class  DragDataGrid : System.Web.UI.Page
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        
protected System.Web.UI.WebControls.DataGrid DataGrid1;
InBlock.gif        
private string constring="";
InBlock.gif        
private void Page_Load(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
string sql="select * from testgrid";
InBlock.gif            DataSet ds
=GetDataSet(sql);
InBlock.gif            
this.DataGrid1.DataSource=ds;
InBlock.gif            
this.DataGrid1.DataBind();
ExpandedSubBlockEnd.gif        }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
GetDataSet#region GetDataSet
InBlock.gif        
private DataSet GetDataSet(string sql)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            constring
=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
InBlock.gif            SqlDataAdapter    sda 
=new SqlDataAdapter(sql,constring);
InBlock.gif            DataSet ds
=new DataSet();
InBlock.gif            sda.Fill(ds);
InBlock.gif            
return ds;
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
Web Form Designer generated code#region Web Form Designer generated code
InBlock.gif        
override protected void OnInit(EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//
InBlock.gif            
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
InBlock.gif            
//
InBlock.gif
            InitializeComponent();
InBlock.gif            
base.OnInit(e);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Required method for Designer support - do not modify
InBlock.gif        
/// the contents of this method with the code editor.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{    
InBlock.gif            
this.Load += new System.EventHandler(this.Page_Load);
InBlock.gif
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

ExpandedBlockEnd.gif    }
3.源代码下载 /Files/singlepine/draggridcol.rar

转载于:https://www.cnblogs.com/cheatlove/articles/405388.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值