private bool Valid() { try { gvDetail.CloseEditor(); gvDetail.CloseEditForm(); gvDetail.FocusedColumn = colLandCodes; gvDetail.FocusedColumn = colSegmentID; if (gvDetail.FocusedRowHandle < 0) { return(true); } TraJunctionSegInfo Curr = bsDetail[gvDetail.FocusedRowHandle] as TraJunctionSegInfo; if (Curr == null) { return(false); } if (string.IsNullOrEmpty(Curr.LandCodes)) { return(false); } if (!(Curr.LandCodes.StartsWith(",") && Curr.LandCodes.EndsWith(","))) { MsgBox.ShowWarn("地标集未以逗号开头或结尾!"); return(false); } return(true); } catch (Exception ex) { MsgBox.ShowError(ex.Message); return(false); } }
private void btnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { gvDetail.CloseEditor(); gvDetail.CloseEditForm(); gvDetail.FocusedColumn = colSegmentID; if (bsDetail.Count > 0 && !Valid()) { return; } TraJunctionSegInfo newItem = new TraJunctionSegInfo(); newItem.SegmentID = bsDetail.Count + 1; bsDetail.Add(newItem); bsDetail.ResetBindings(false); bsDetail.MoveLast(); } catch (Exception ex) { MsgBox.ShowError(ex.Message); } }