Saturday, March 29, 2014

Check And Uncheck DataGridView Cell

If DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = "P" Then
                DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = ""
            Else
                DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.Font = New Font("Wingdings 2", 14, FontStyle.Bold)
                DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = "P"
            End If

Monday, March 24, 2014

insert update using db class

Frist add --- app.config
and write the code under app.config------
------------------------------
    [appSettings ]
   [add key ="cont1" value ="server=.;trusted_connection=yes;database=stest" /]
 [/appSettings]
     ------------------------------
###############write the code under db class################
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Public Class db
    Public cont As String = ConfigurationSettings.AppSettings("cont1")

    Public Function getdata(ByVal myqry As String) As DataTable  'This function use getdata from db

        Dim cn As New SqlConnection(cont)
        Dim ds As New DataSet
        Dim td As New DataTable
        Try
            Dim da As New SqlDataAdapter(myqry, cn)
            da.Fill(ds)
            td = ds.Tables(0)
        Catch ex As Exception
        End Try
        Return td
    End Function

    Public Function excute(ByVal myqry As String) As Boolean  'This function insert,update data in to  db

        Dim cn As New SqlConnection(cont)
        Dim ds As New DataSet
        Try
            Dim da As New SqlDataAdapter(myqry, cn)
            da.Fill(ds)
        Catch ex As Exception
            MsgBox(ex.Message)
            Return False
        End Try
        Return True
    End Function
End Class
###############################################

Saturday, March 22, 2014

open image in picturebox in vb.net

 Dim open As New OpenFileDialog()
        open.Filter = "Image Files(*.png; *.jpg; *.bmp)|*.png; *.jpg; *.bmp"
        If open.ShowDialog() = DialogResult.OK Then
            Dim fileName As String = System.IO.Path.GetFullPath(open.FileName)
            PictureBox1.Image = New Bitmap(open.FileName)
            Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
        End If

Tuesday, March 11, 2014

click first column content in datagridview vb.net

  If gridshot.Columns(e.ColumnIndex).Name = "Select" Then

Do not Allow Sorting in Data Grid View

 Private Sub gridshot_ColumnAdded(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewColumnEventArgs) Handles gridshot.ColumnAdded
        gridshot.Columns.Item(e.Column.Index).SortMode = DataGridViewColumnSortMode.NotSortable
    End Sub