为什么,我的DevExpress.XtraGrid.GridControl不能显示数据
1个回答
展开全部
1,增加新行用InitNewRow事件,给新行某字段赋值。后结束编辑。
private void grdView_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
{
DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
view.SetRowCellValue(e.RowHandle, view.Columns["EnterID"], this.dS_MEnterStoreView.MEnterStore[0].ID);
this.grdControl.EmbeddedNavigator.Buttons.EndEdit.DoClick();
this.grdView.UpdateCurrentRow();
}
2,如果进行行验证,就在换行时时行,用grdView_FocusedRowChanged事件。
private void grdView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
WsClient.WS_MEnterStore.DS_MEnterStoreView.MEnterDetailRow row = (WsClient.WS_MEnterStore.DS_MEnterStoreView.MEnterDetailRow)this.grdView.GetDataRow(e.FocusedRowHandle);
if (row != null)
{
if ((this.OperState == Common.Enum.TOperState.UnConfirmNew)
|| (this.OperState == Common.Enum.TOperState.UnConfirmEdit))
{
this.InitComboBoxValue(row, row.IsGoodIDNull()?0:row.GoodID, false);
this.InitBatchComboBoxValue(row, row.IsGoodIDNull()?0:row.GoodID, false);
}
}
}
3,如果需要改变行的某一列的同时改变其它的列用grdView_CellValueChanged事件。
private void grdView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
if (this.grdView.FocusedColumn == e.Column)
{
if (e.Column == this.colAmount)
{
}
}
}
4,如果需在离开行的时候需要验证,则用grdView_BeforeLeaveRow事件。
private void grdView_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
{
DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
view.SetRowCellValue(e.RowHandle, view.Columns["EnterID"], this.dS_MEnterStoreView.MEnterStore[0].ID);
this.grdControl.EmbeddedNavigator.Buttons.EndEdit.DoClick();
this.grdView.UpdateCurrentRow();
}
2,如果进行行验证,就在换行时时行,用grdView_FocusedRowChanged事件。
private void grdView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
WsClient.WS_MEnterStore.DS_MEnterStoreView.MEnterDetailRow row = (WsClient.WS_MEnterStore.DS_MEnterStoreView.MEnterDetailRow)this.grdView.GetDataRow(e.FocusedRowHandle);
if (row != null)
{
if ((this.OperState == Common.Enum.TOperState.UnConfirmNew)
|| (this.OperState == Common.Enum.TOperState.UnConfirmEdit))
{
this.InitComboBoxValue(row, row.IsGoodIDNull()?0:row.GoodID, false);
this.InitBatchComboBoxValue(row, row.IsGoodIDNull()?0:row.GoodID, false);
}
}
}
3,如果需要改变行的某一列的同时改变其它的列用grdView_CellValueChanged事件。
private void grdView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
if (this.grdView.FocusedColumn == e.Column)
{
if (e.Column == this.colAmount)
{
}
}
}
4,如果需在离开行的时候需要验证,则用grdView_BeforeLeaveRow事件。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询