本站首页    管理页面    写新日志    退出

The Neurotic Fishbowl

[.NET-Winform]grid 的列添加及数值改变
麦林 发表于 2007/12/4 16:49:23

        protected override void JeezFilterUI_Load(object sender, EventArgs e)        {            grid1 = base.GetControlByName("JeezGrid1") as Jeez.Control.JeezGrid.JeezGrid;            butadd = base.GetControlByName("JeezButton1") as Jeez.Control.UltraButton.JeezUltraButton;            butdel = base.GetControlByName("JeezButton2") as Jeez.Control.UltraButton.JeezUltraButton;             grid1.RowCount = 1;            grid1.Rows[0].Cells["ts"].Value = DBNull.Value;            grid1.Rows[0].Cells["bt"].Value = "到截止日期为止";             grid1.AllowResponseCellUpdate = true;        }         private void JeezGrid1_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)        {            if (e.Cell.Column.Key.Equals("ts"))            {                if (e.Cell.Row.Index == 0)                {                    if (e.Cell.Row.Index == grid1.RowCount - 1)                    {                        if (e.Cell.Value != DBNull.Value && e.Cell.Value.ToString() != "0" && e.Cell.Value.ToString() != "")                            e.Cell.Row.Cells["bt"].Value = "1至" + e.Cell.Value.ToString() + "天";                    }                    if (e.Cell.Row.Index != grid1.RowCount - 1)                    {                        if (e.Cell.Value != DBNull.Value && e.Cell.Value.ToString() != "0" && e.Cell.Value.ToString() != "")                        {                            if (Convert.ToInt32(e.Cell.Row.Cells["ts"].Value.ToString()) < Convert.ToInt32(grid1.Rows[e.Cell.Row.Index + 1].Cells["ts"].Value.ToString()) && grid1.Rows[e.Cell.Row.Index + 1].Cells["ts"].Value.ToString() != "0" && grid1.Rows[e.Cell.Row.Index + 1].Cells["ts"].Value.ToString() != "" && grid1.Rows[e.Cell.Row.Index + 1].Cells["ts"].Value != DBNull.Value)                            {                                e.Cell.Row.Cells["bt"].Value = "1至" + e.Cell.Value.ToString() + "天";                                grid1.Rows[e.Cell.Row.Index + 1].Cells["bt"].Value = Convert.ToString(Convert.ToInt32(e.Cell.Value.ToString()) + 1) + "至" + grid1.Rows[e.Cell.Row.Index + 1].Cells["ts"].Value.ToString() + "天";                            }                            else                            {                                MessageBox.Show("后一个帐龄的天数必须大于前一个的天数", "提示", MessageBoxButtons.OK);                                e.Cell.Row.Cells["ts"].CancelUpdate();                                e.Cell.Row.Cells["ts"].Value = e.Cell.Row.Cells["ts"].OriginalValue;                            }                        }                         if (e.Cell.Value == DBNull.Value || e.Cell.Value.ToString() == "0" || e.Cell.Value.ToString() == "")                        {                            grid1.RowCount = 1;                            grid1.Rows[0].Cells["ts"].Value = DBNull.Value;                            grid1.Rows[0].Cells["bt"].Value = "到截止日期为止";                        }                    }                }                 if (e.Cell.Row.Index > 0 && e.Cell.Row.Index == grid1.RowCount - 1)                {                    if (e.Cell.Value == DBNull.Value || e.Cell.Value.ToString() == "0" || e.Cell.Value.ToString() == "")                    {                        e.Cell.Row.Cells["bt"].Value = grid1.Rows[e.Cell.Row.Index - 1].Cells["ts"].Value.ToString() + "以上";                    }                    if (e.Cell.Value != DBNull.Value && e.Cell.Value.ToString() != "0" && e.Cell.Value.ToString() != "")                    {                        if (Convert.ToInt32(grid1.Rows[e.Cell.Row.Index - 1].Cells["ts"].Value.ToString()) < Convert.ToInt32(e.Cell.Row.Cells["ts"].Value.ToString()))                        {                            e.Cell.Row.Cells["bt"].Value = Convert.ToString(Convert.ToInt32(grid1.Rows[e.Cell.Row.Index - 1].Cells["ts"].Value.ToString()) + 1) + "至" + e.Cell.Value.ToString() + "天";                        }                        else                        {                            MessageBox.Show("后一个帐龄的天数必须大于前一个的天数", "提示", MessageBoxButtons.OK);                            e.Cell.Row.Cells["ts"].CancelUpdate();                            e.Cell.Row.Cells["ts"].Value = e.Cell.Row.Cells["ts"].OriginalValue;                         }                    }                }                if (e.Cell.Row.Index != 0 && e.Cell.Row.Index != grid1.RowCount - 1)                {                    if (e.Cell.Value == DBNull.Value || e.Cell.Value.ToString() == "0" || e.Cell.Value.ToString() == "")                    {                        grid1.RowCount = e.Cell.Row.Index + 1;                        e.Cell.Row.Cells["bt"].Value = grid1.Rows[e.Cell.Row.Index - 1].Cells["ts"].Value.ToString() + "以上";                    }                    else                    {                        if (Convert.ToInt32(grid1.Rows[e.Cell.Row.Index - 1].Cells["ts"].Value.ToString()) < Convert.ToInt32(e.Cell.Row.Cells["ts"].Value.ToString()) && Convert.ToInt32(grid1.Rows[e.Cell.Row.Index + 1].Cells["ts"].Value.ToString()) > Convert.ToInt32(e.Cell.Row.Cells["ts"].Value.ToString()) && grid1.Rows[e.Cell.Row.Index + 1].Cells["ts"].Value.ToString() != "0" && grid1.Rows[e.Cell.Row.Index + 1].Cells["ts"].Value.ToString() != "" && grid1.Rows[e.Cell.Row.Index + 1].Cells["ts"].Value != DBNull.Value)                        {                            e.Cell.Row.Cells["bt"].Value = Convert.ToString(Convert.ToInt32(grid1.Rows[e.Cell.Row.Index - 1].Cells["ts"].Value.ToString()) + 1) + "至" + e.Cell.Value.ToString() + "天";                            grid1.Rows[e.Cell.Row.Index + 1].Cells["bt"].Value = Convert.ToString(Convert.ToInt32(e.Cell.Value.ToString()) + 1) + "至" + grid1.Rows[e.Cell.Row.Index + 1].Cells["ts"].Value.ToString() + "天";                        }                        else                        {                            MessageBox.Show("后一个帐龄的天数必须大于前一个的天数", "提示", MessageBoxButtons.OK);                            e.Cell.Row.Cells["ts"].CancelUpdate();                            e.Cell.Row.Cells["ts"].Value = e.Cell.Row.Cells["ts"].OriginalValue;                        }                    }                }            }        }         private void JeezButton1_Click(object sender, EventArgs e) //增加行        {            if (grid1.Rows[grid1.RowCount - 1].Cells["ts"].Value != DBNull.Value && grid1.Rows[grid1.RowCount - 1].Cells["ts"].Value.ToString() != "" && grid1.Rows[grid1.RowCount - 1].Cells["ts"].Value.ToString() != "0")            {                grid1.InsertRow(grid1.RowCount);                grid1.Rows[grid1.RowCount - 1].Cells["bt"].Value = grid1.Rows[grid1.RowCount - 2].Cells["ts"].Value.ToString() + "以上";            }        }         private void JeezButton2_Click(object sender, EventArgs e) //删除行        {            foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in grid1.Rows.All)            {                if (row.Selected == true)                {                    grid1.Rows[row.Index].Delete();                    //删第一行且大于等于2行                    if (grid1.RowCount > 0 && row.Index == 0)                        grid1.Rows[row.Index].Cells["bt"].Value = "1" + grid1.Rows[row.Index].Cells["ts"].Value.ToString().Substring(grid1.Rows[row.Index].Cells["ts"].Value.ToString().LastIndexOf('至'), grid1.Rows[row.Index].Cells["ts"].Value.ToString().Length);                    //删中间行                    if (grid1.RowCount > 0 && row.Index > 0 && row.Index != grid1.RowCount - 1)                        grid1.Rows[row.Index].Cells["bt"].Value = grid1.Rows[row.Index - 1].Cells["ts"].Value.ToString() + row.Cells + grid1.Rows[row.Index].Cells["ts"].Value.ToString().Substring(grid1.Rows[row.Index].Cells["ts"].Value.ToString().LastIndexOf('至'), grid1.Rows[row.Index].Cells["ts"].Value.ToString().Length);                 }            }        }

阅读全文(2531) | 回复(0) | 编辑 | 精华

 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)
 

The Neurotic Fishbowl

.: 公告

fighting for the work!


Bloginess

«October 2025»
1234
567891011
12131415161718
19202122232425
262728293031

.: 我的分类(专题)

首页(449)
文字感悟(103)
学习公共库(61)
生活体会(100)
资源收集(14)
.NET-Winform(27)
音乐文字(15)
心情小记(119)
SQL问题解决(10)


In the Bowl

.: 最新日志

C#打印代码
你看到的我是蓝色的
即将逝去的3月
这个假期
两个月过去
表名存在其他表时获取数据
条码打印
Remoting的用法
INI文件用法


.: 最新回复

回复:条码打印
回复:条码打印
回复:即将逝去的3月
回复:cookie对象使用
回复:条码打印
回复:JSP学习(字符串比较)
回复:应收应付核销规则及常见问题(续)
回复:两个月过去
回复:两个月过去


The Fishkeeper
blog名称:栗色?蓝色?
日志总数:449
评论数量:201
留言数量:37
访问次数:2268214
建立时间:2006年5月16日



Text Me

.: 留言板

签写新留言

链接完成
回:loseVC
来喽~
转转......
新年啦
对自己说
祝福
回:佑手
WO


Other Fish in the Sea

.: 链接


loseVC's BLOG
Collapsar_feel
布衣加针
C#and.Net
Kinogam Web




站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.063 second(s), page refreshed 144827298 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号