Apr 16

Visual Basic 2010 – Event Log Sample

Description: The component, used in this sample, provides access to the operating system event logs. You can add and delete logs, add and remove event log sources, write messages, and delete messages. The main form, Form1, contains three controls to read, write, and create or delete event logs. Each opens a new form that collects information specific to the operation. The form WriteForm collects the text, ID, and type for an event-log entry and writes the entry to the Application event log using the method. The form ReadForm fills a control with the names of the event logs on the computer. The list is obtained by calling the method, and then displaying the value of the property for each log. The last ten entries of the selected log are retrieved with property and then displayed in a control. Download Project

 

 

 

 

 

 

Screenshot

Apr 14

Visual Basic .Net – Datagrid CurrentCell.RowIndex and CurrentCell.ColumnIndex

Description: Visual Basic .Net sample code on DatagridView CurrentRowIndex, CurrentCell.ColumnIndex and DataGridView1.CurrentCell.Value.

 

 

 

 

 

 

Source Code

Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
        Dim iRow As Integer, iCol As Integer, cData As String
        iRow = DataGridView1.CurrentCell.RowIndex + 1
        iCol = DataGridView1.CurrentCell.ColumnIndex + 1
        cData = DataGridView1.CurrentCell.Value
        MsgBox("Row(" & iRow & ") Column(" & iCol & ") Value is[" & cData & "]")
    End Sub
Apr 14

Visual Basic .Net Selected Current Row and Current Column on Datagrid

Description: A simple visual basic .net code to get the selected current row and column on the datagridview.

 

 

 

 

 

 

Visual Basic .Net Source Code

Private Sub songsDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
'This code will select the current row and current column of the datagridview
Dim cData As String
   If DataGridView1.RowCount > 0 Then
      cData = DataGridView1.CurrentCell.Value
      MsgBox(cData)
   End If
End Sub
Apr 14

Visual Basic 2010 Create Context Menu / Popup Menu, Read CSV and Datagridview Select

Description: Visual Basic sample on how to create a context menu or popup menu. This sample also includes on how to read csv file or comma separated values and select current row and column on datagridview sample using DataGridView1.CurrentCell.RowIndex, DataGridView1.CurrentCell.ColumnIndex and DataGridView1.CurrentCell.Value. Download Project

 

 

 

 

 

 

Screenshot

Apr 13

Visual Basic .Net How to Close All Forms Except Main Form

Description : A Visual Basic .Net sample code on how to close all forms except the main form.
Version: All Visual Basic .Net

 

 

 

 

 

 

 

Source Code

'Sample 1
'Close all forms except main form
For i As Integer = My.Application.OpenForms.Count - 1 To 0 Step -1
            If My.Application.OpenForms.Item(i) IsNot Me Then
                My.Application.OpenForms.Item(i).Close()
            End If
Next i

'Sample 2
'Close all forms except main and frmlogin form
For i As Integer = My.Application.OpenForms.Count - 1 To 0 Step -1
            If My.Application.OpenForms.Item(i) IsNot Me And My.Application.OpenForms.Item(i) IsNot frmlogin Then
                My.Application.OpenForms.Item(i).Close()
            End If
Next i