1.获取字段的VisibleIndex属性
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
{ if (e.Column.VisibleIndex == 4)//文件点击事件 { string wi_file_oldname = this.gridView1.GetRowCellValue(e.RowHandle, "wi_file_oldname").ToString(); string wi_file_name = this.gridView1.GetRowCellValue(e.RowHandle, "wi_file_name").ToString(); if (string.IsNullOrWhiteSpace(wi_file_name)||string.IsNullOrWhiteSpace(wi_file_oldname)) return;string wangpanPath = InitClass.ReadString("application", "WANGPAN_IP", "");
wangpanPath = wangpanPath + "\\WI"; if (string.IsNullOrWhiteSpace(wangpanPath)|| Directory.Exists(wangpanPath)==false) { MessageBox.Show("路径不存在!","提示"); return; } else { string filePath = wangpanPath + "\\" + wi_file_name; if (File.Exists(filePath)) { //打开文件System.Diagnostics.Process.Start(filePath);
} else { MessageBox.Show("文件不存在!"); return; } } } if (e.Column.VisibleIndex == 7)//任务启动事件 { if (this.gridView1.FocusedRowHandle < 0) return; int id = (int)this.gridView1.GetFocusedRowCellValue("wi_id"); DateTime dtTime = Convert.ToDateTime(DateTime.Now.ToString("G")); int selectRow = gridView1.GetSelectedRows()[0]; string tasktime = this.gridView1.GetRowCellValue(selectRow, "task_start_time").ToString(); if (string.IsNullOrWhiteSpace(tasktime) == false) { dtTime = Convert.ToDateTime(tasktime); } DateTime lastTime = Convert.ToDateTime(DateTime.Now.ToString("G")); int check= (int)this.gridView1.GetFocusedRowCellValue("IsStart");if (check == 0)
{ if (wi_bll.Edit_wi_task(id, dtTime, lastTime,1)) {this.repositoryItemCheckEdit1.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.InactiveChecked;
this.gridView1.SetRowCellValue(selectRow, "IsStart", 1); MessageBox.Show("设定时间成功,任务已启动!", "提示"); } } else { wi_bll.Edit_wi_task(id, dtTime, lastTime, 0); this.repositoryItemCheckEdit1.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked; this.gridView1.SetRowCellValue(selectRow, "IsStart", 0); MessageBox.Show("取消任务成功"); } } }
2.每一个成功的人都付出了双倍的时间和经历去做研究