找回密码
 立即注册

QQ登录

只需一步,快速开始

junlingzhu2002

银牌会员

38

主题

150

帖子

3344

积分

银牌会员

积分
3344

活字格认证

junlingzhu2002
银牌会员   /  发表于:2012-2-23 09:26  /   查看:5556  /  回复:9
我在第2行得CELL中输入“.”用GetValue来取得,
昨天还可以,今天怎么就突然不行了?

9 个回复

倒序浏览
robert
金牌服务用户   /  发表于:2012-2-23 15:16:00
沙发
什么叫忽然不行了?怎么个不行法?
回复 使用道具 举报
junlingzhu2002
银牌会员   /  发表于:2012-2-23 15:27:00
板凳
在昨天发的例子中插入下面的程序
    Private Sub mrMit05_CellValidating(ByVal sender As Object, ByVal e As GrapeCity.Win.MultiRow.CellValidatingEventArgs) Handles mrMit05.CellValidating
        'ピリオド入力の処理
        Sub_PeriodCheck(sender, e)
    End Sub
    Private Sub Sub_PeriodCheck(ByVal sender As Object, ByRef e As GrapeCity.Win.MultiRow.CellValidatingEventArgs)
        Try
            Dim strName As String = DirectCast(sender, Control).Name
            Dim strGyo As Integer = e.RowIndex
            Dim strValue As String = String.Empty
            Dim strCode As String = String.Empty
            Dim strPreCode As String = String.Empty
            Dim strPreFax As String = String.Empty
            Dim strPreShiTan As String = String.Empty
            Dim strValueP As Object = mrMit05.GetValue(e.RowIndex, e.CellIndex)

            If mrMit05(e.RowIndex, e.CellIndex).Name = "txt_SHO_NAME" Or _
                mrMit05(e.RowIndex, e.CellIndex).Name = "txt_KIKAKI" Or _
                mrMit05(e.RowIndex, e.CellIndex).Name = "txt_SHIKEY" Or _
                mrMit05(e.RowIndex, e.CellIndex).Name = "cmb_SHINAME" Or _
                mrMit05(e.RowIndex, e.CellIndex).Name = "txt_SHIFAXNO" Or _
                mrMit05(e.RowIndex, e.CellIndex).Name = "txt_SHITAN" Or _
                mrMit05(e.RowIndex, e.CellIndex).Name = "txt_KOBETUNOKI" Or _
                mrMit05(e.RowIndex, e.CellIndex).Name = "txt_MEISAIBIKO" Then

                If mrMit05.GetValue(e.RowIndex, e.CellIndex) Is "." Or mrMit05.GetValue(e.RowIndex, e.CellIndex) Is "." Then
                    '1行目はエラー
                    If e.RowIndex = 0 Then
                        MessageBox.Show("1行目でピリオドは入力できません")
                        e.Cancel = True
                        Exit Sub
                    Else
                        '前行コピー
                        mrMit05.SetValue(e.RowIndex, e.CellIndex, mrMit05.GetValue(e.RowIndex - 1, e.CellIndex))
                    End If

                End If
            End If
        Catch ex As Exception
        End Try
    End Sub
昨天试验的可以实现,早上不知怎么了,就是不成功,不好意思,
拜托你再帮检查一下吧。
回复 使用道具 举报
junlingzhu2002
银牌会员   /  发表于:2012-2-23 15:29:00
地板
程序发错了
Private Sub MyGcMultiRow1_CellValidating(ByVal sender As Object, ByVal e As GrapeCity.Win.MultiRow.CellValidatingEventArgs) Handles MyGcMultiRow1.CellValidating
        'ピリオド入力の処理
        Sub_PeriodCheck(sender, e)
    End Sub
    Private Sub Sub_PeriodCheck(ByVal sender As Object, ByRef e As GrapeCity.Win.MultiRow.CellValidatingEventArgs)
        If MyGcMultiRow1(e.RowIndex, e.CellIndex).Name = "txtShoNm" Or _
             MyGcMultiRow1(e.RowIndex, e.CellIndex).Name = "txtShoKana" Then

            If MyGcMultiRow1.GetValue(e.RowIndex, e.CellIndex) Is "." Or MyGcMultiRow1.GetValue(e.RowIndex, e.CellIndex) Is "." Then
                '1行目はエラー
                If e.RowIndex = 0 Then
                    MessageBox.Show("1行目でピリオドは入力できません")
                    e.Cancel = True
                    Exit Sub
                Else
                    '前行コピー
                    MyGcMultiRow1.SetValue(e.RowIndex, e.CellIndex, MyGcMultiRow1.GetValue(e.RowIndex - 1, e.CellIndex))
                End If

            End If
        End If
    End Sub
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2012-2-23 16:13:00
5#
在CellValidating函数里建议使用e.FormattedValue. 而不是用用GetValue方法。
回复 使用道具 举报
junlingzhu2002
银牌会员   /  发表于:2012-2-23 16:23:00
6#
我试试看,可不可以实现,
SetValue可以直接用是吗?
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2012-2-23 16:37:00
7#
在这个Case下应该是可以的。
回复 使用道具 举报
junlingzhu2002
银牌会员   /  发表于:2012-2-23 16:51:00
8#
谢谢,
不过还是不成功,
入力后,Tab或Enter键,跳出CELl,再进入,再跳出时,才会触发上面的程序。
是不是还是和CELL处在编辑状态有关,
我再考虑考虑。
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2012-2-23 17:16:00
9#
我把你的代码改了下,你试试可以了吗?

  1.     Private Sub Sub_PeriodCheck(ByVal sender As Object, ByRef e As GrapeCity.Win.MultiRow.CellValidatingEventArgs)
  2.         If MyGcMultiRow1(e.RowIndex, e.CellIndex).Name = "txtShoNm" Or _
  3.         MyGcMultiRow1(e.RowIndex, e.CellIndex).Name = "txtShoKana" Then
  4.             If e.FormattedValue IsNot Nothing Then
  5.                 If e.FormattedValue.ToString() = "." Or e.FormattedValue.ToString() = "." Then
  6.                     'ピリオド入力の処理
  7.                     If e.RowIndex = 0 Then
  8.                         MessageBox.Show("1行目でピリオドは入力できません")
  9.                         e.Cancel = True
  10.                         Exit Sub
  11.                     Else
  12.                         '1行目はエラー
  13.                         If (MyGcMultiRow1.GetValue(e.RowIndex - 1, e.CellIndex) IsNot Nothing) Then
  14.                             MyGcMultiRow1.EditingControl.Text = MyGcMultiRow1.GetValue(e.RowIndex - 1, e.CellIndex).ToString()
  15.                             'MyGcMultiRow1.SetValue(e.RowIndex, e.CellIndex, MyGcMultiRow1.GetValue(e.RowIndex - 1, e.CellIndex))
  16.                         Else
  17.                             MyGcMultiRow1.EditingControl.Text = Nothing
  18.                         End If
  19.                     End If
  20.                 End If
  21.             End If
  22.         End If
  23.     End Sub
复制代码
回复 使用道具 举报
junlingzhu2002
银牌会员   /  发表于:2012-3-9 08:37:00
10#
谢过。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部