2013年5月24日金曜日

vb.net 異常発生時に、発生した行番号を取得



vb.net 異常発生時に、発生した行番号を取得

New StackFrame(True).GetFileLineNumber


使い方例:


            Dim m_strTEMsg As String = String.Empty
            m_strTEMsg &= New StackFrame(True).GetFileLineNumber
            m_strTEMsg &= ","
            m_strTEMsg &= ex.Message.ToString       ' エラー情報
            ErrorLogWrite(m_strTEMsg)

2013年5月23日木曜日

DataGridViewComboBoxColumnの初期値を入れる

DataGridViewComboBoxColumnの初期値を入れる

①まず、DataGridViewのCellFormattingイベントハンドラを追加
②そのイベントハンドラの中、下記を追加
  例の中、DataGridViewComboBoxColumnは第二列にある。
  
Private Sub m_dgvData_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles m_dgvData.CellFormatting
        If e.ColumnIndex = 1 Then ' Index of your DataGridViewComboBoxColumn 
            CType(m_dgvData.Rows(e.RowIndex).Cells(1), DataGridViewComboBoxCell).Value = 1
        End If
    End Sub

vb.net 背景色を消す、Nullにするには

vb.net 背景色を消す、Nullにするには

xx.Style.BackColor = Color.Empty