UltraWebGrid中格式化字符串

本文介绍了一个使用Infragistics UltraWebGrid控件进行布局初始化的方法,包括设置允许删除、更新,默认格式化日期、金额显示,以及如何添加未绑定的列作为描述和汇总列。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

internal void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e) { // Allow for deletion e.Layout.AllowDeleteDefault = AllowDelete.Yes; // allow update for the WebGrid e.Layout.AllowUpdateDefault = AllowUpdate.Yes; UltraGridColumn c; // formats the Date column e.Layout.Bands[0].Columns.FromKey("Date").Format = "MM/dd/yyyy"; // Sets up the format for the Received column c = e.Layout.Bands[0].Columns.FromKey("Received"); c.Format = "$###,###.00"; c.CellStyle.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224))); c.CellStyle.HorizontalAlign = HorizontalAlign.Right; c.DefaultValue = 0; // Sets up the format for the payment column c = e.Layout.Bands[0].Columns.FromKey("Payment"); c.Format = "$###,###.00"; //c.CellStyle.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(128))); c.CellStyle.BackColor = System.Drawing.Color.LightYellow; c.CellStyle.HorizontalAlign = HorizontalAlign.Right; c.DefaultValue = 0; // Adds an unbound column for the description field and moves it into the 2nd column slot e.Layout.Bands[0].Columns.Add("Description", "Description"); c = e.Layout.Bands[0].Columns.FromKey("Description"); c.Move(1); // Adds an unbound column to act as a summary column e.Layout.Bands[0].Columns.Add("Balance","Balance"); c = e.Layout.Bands[0].Columns.FromKey("Balance"); c.Format = "$###,###.00"; c.CellStyle.BackColor = System.Drawing.Color.LightSteelBlue; c.CellStyle.HorizontalAlign = HorizontalAlign.Right; // turn off editing of the last column c.AllowUpdate = AllowUpdate.No; // sets up the backcolor on the lables this.ulCurrentBalance.BackColor = Color.LightSteelBlue; this.ulPayable.BackColor = Color.LightYellow; this.ulReceivable.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224))); }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值