当我在vb.net中使用以下内容将数据绑定到网格视图时,它工作正常,可以编辑单元格,但当我声明列名时,它不允许我编辑单元格值
Dim bs As New BindingSource
bs.DataSource = (From u In threeContext.dbContext.skechersDeliveries Where u.isprocessed = False Select u)
bs.ResetBindings(True)
dgDeliverys.DataSource = bs
这是一个例子我会如何删除列名而不是slect u我会在下面有一些谎言
Select New With
{
Leave.Id,
Leave.Leave_Month,
Leave.Leave_App_Date,
Leave.Leave_From_Date, Leave.Leave_To_Date, Emp.EmplName, Leavetype.LeaveDesc, Leave.Leave_Day
}
我正在使用以下选择
订单号将bs Dim为新绑定源
Dim cfglocation As Int16
cfglocation = cfb.StoreLocation
bs.DataSource = (From u In threeContext.dbContext.R3Delivery Where u.isprocessed = False AndAlso u.location = cfglocation
Select OrderNumber = u.ordernumber, BarCode = u.tagbarcode, Qty = u.qty, Processed = u.isprocessed, NotDelivered = u.isDelivered)
bs.ResetBindings(True)
dgDeliverys.DataSource = bs
dgDeliverys.Columns(0).ReadOnly = True
dgDeliverys.Columns(1).ReadOnly = True
dgDeliverys.Columns(2).ReadOnly =true
第三列是qtry,当你看到它们的i停在2时,它应该是可以更改的,但当我声明上面的列名时,我不能再双击并直接编辑数据网格
我认为你应该。。。。
Dim bs As New BindingSource
bs.DataSource = (From u In threeContext.dbContext.skechersDeliveries
Where u.isprocessed = False
Select New With{.ID = u.FieldThatMapsToID,
.LeaveMonth = u.FieldThatMapsToLeaveMonth,
.......
.Leave_Day = u.FieldThatMapsToLeave_Day})
bs.ResetBindings(True)
dgDeliverys.DataSource = bs