English 中文(简体)
同一栏下价值变动后其他栏的变动值
原标题:Change values of other columns in same row upon change of value on one column

I m 书写VB的桌面应用程序。 Net using a 。 如果浏览量变化中的任何一栏价值,我必须在同一行中重新计算其他栏目的价值。

下面是<代码”的范例。 反对List 观点目前显示:

Unit Name Length Height Qty Rate Amount
MM 10 15 150 10.00 1500
CMS 15 5 75 8.00 600
IN 12 5 60 24.00 1440
MTR 11 6 66 18.00 1188

<代码>Qty 页: 1 当用户在<代码>Length栏和<代码>第15栏进入时。 Height栏,Qty 栏将显示价值为150(10*15)。

同样,<代码>Amount按<代码>Rate*>计算。 当用户进入<代码>Rate时,数额栏将显示价值为1500(150*10.00)。

我很难找到合适的<密码>。 反对List 浏览量变化时用于计算单位值的活动。

我多次试图开展各种活动,但最近的一次尝试如下。 我试图为用户正在进入价值但失败的囚室打上一整条灯标。 然后,我尝试将<代码>e.RowObject投到我的班子上ClientTask,希望e.RowObject将整整整整行,但该插文中将有一个例外。 我还尝试在<代码>e.Column.AspectName上开展工作,但我不敢肯定如何将新的价值观重新用于这一模式。

我如何能够这样做? 我赞赏你能够提供的任何帮助。

Private Sub dlvEstimateTemplate_CellEditFinishing(sender As Object, e As CellEditEventArgs) Handles dlvEstimateTemplate.CellEditFinishing
        Dim lngth As Single = 0      Length
        Dim ht As Single = 0         Height
        Dim qty As Single = 0        Quantity (Length * Height = Qty)
        Dim rt As Single = 0
        Dim amt As Single = 0
        Dim myObj As Entities.ClientTask
        Dim myTsk As Entities.ClientTask


         tmpVal = DirectCast(sender, BrightIdeasSoftware.DataListView).HotRowIndex
         DirectCast(sender, BrightIdeasSoftware.DataListView).GetItemAt(e.x

         myObj = e.RowObject
        If e.Column.AspectName = "Length" Then
            myTsk = New Entities.ClientTask
            myTsk.Qty = e.NewValue * myTsk.Height
            myTsk.Amt = myTsk.Qty * myTsk.Rate
             lngth = e.NewValue
        ElseIf e.Column.AspectName = "Height" Then
            myTsk = New Entities.ClientTask
            myTsk.Qty = e.NewValue * myTsk.Length
            myTsk.Amt = myTsk.Qty * myTsk.Rate
        End If
        DirectCast(sender, BrightIdeasSoftware.DataListView).BuildList()
         myObj = TryCast(e.RowObject, Entities.ClientTask)
    End Sub
问题回答

我最后要找到解决办法,尽管我感到,随着它利用我觉得不是一种理想的解决办法的多功能通路,它可以进一步优化。 如果任何人能够进一步协助提炼,特别是不参加输油,那将真正有助于:

Private Sub dlvEstimateTemplate_CellEditFinishing(sender As Object, e As CellEditEventArgs) Handles dlvEstimateTemplate.CellEditFinishing UpdateRowCalc03(sender, e) End Sub

Private Sub UpdateRowCalc03(ByVal mySender As Object, ByVal myE As CellEditEventArgs)
    Dim rowId As Integer
    Dim lngth As Single = 0      Length
    Dim ht As Single = 0         Height
    Dim qty As Single = 0        Quantity (Length * Height = Qty)
    Dim rt As Single = 0         Rate
    Dim amt As Single = 0        Amount (Qty * Rate)

    rowId = myE.ListViewItem.SubItems(0).Text
    For Each itm As ListViewItem In dlvEstimateTemplate.Items
        If Convert.ToInt32(itm.SubItems(0).Text) = rowId Then
            If myE.Column.AspectName = olvColLength.AspectName Then              Length
                lngth = myE.NewValue
                ht = Convert.ToSingle(myE.ListViewItem.SubItems(5).Text)         Height
                qty = lngth * ht                                                 Qty
                rt = Convert.ToSingle(myE.ListViewItem.SubItems(7).Text)         Rate
                CommitToDataTable(rowId, rt, qty)
            ElseIf myE.Column.AspectName = olvColHeight.AspectName Then          Height
                ht = myE.NewValue                                                Height
                lngth = Convert.ToSingle(myE.ListViewItem.SubItems(4).Text)      Length
                qty = lngth * ht                                                 Qty
                rt = Convert.ToSingle(myE.ListViewItem.SubItems(7).Text)         Rate
                CommitToDataTable(rowId, rt, qty)
            ElseIf myE.Column.AspectName = olvColRate.AspectName Then            Rate
                lngth = Convert.ToSingle(myE.ListViewItem.SubItems(4).Text)
                ht = Convert.ToSingle(myE.ListViewItem.SubItems(5).Text)         Height
                qty = lngth * ht                                                 Qty
                rt = myE.NewValue                                                Rate
                CommitToDataTable(rowId, rt, qty)
            End If
        End If
    Next
End Sub

Private Sub CommitToDataTable(ByVal rowId As Integer, ByVal myRt As Single, ByVal myQty As Single)
    For Each row As DataRow In dtTable.Rows          dtTable is a form scoped data table object
        For Each myRow As DataRow In dtTable.Rows
            If myRow("UniqueId") = rowId Then
                myRow("Qty") = myQty
                myRow("Amt") = myRt * myQty
            End If
        Next myRow
    Next row
End Sub




相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签