[.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);
} } }
|
|
|

.: 公告
|
« | October 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | |
|
.: 我的分类(专题)
|

.: 最新日志
.: 最新回复
|

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

.: 留言板
|

.: 链接
|

|