Skip to main content

Datagridview complete Guide Vb.net | TechByMati



    DataGridView summary on Footer Vb.Net

    Imports System.Drawing

    Imports System.Data.SqlClient

    Imports System.Data

    Partial Class _Default

    Inherits System.Web.UI.Page

    Dim total As Integer = 0

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim adapter As New SqlDataAdapter()

    Dim ds As New DataSet()

    Dim i As Integer = 0

    Dim sql As String = Nothing

    Dim connetionString As String = "Data Source=.;Initial Catalog=pubs;User ID=sa;Password=*****"

    sql = "select top 6 ord_num,stor_id,title_id,payterms,qty from sales"

    Dim connection As New SqlConnection(connetionString)

    connection.Open()

    Dim command As New SqlCommand(sql, connection)

    adapter.SelectCommand = command

    adapter.Fill(ds)

    adapter.Dispose()

    command.Dispose()

    connection.Close()

    GridView1.DataSource = ds.Tables(0)

    GridView1.DataBind()

    End Sub

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)

    If e.Row.RowType = DataControlRowType.DataRow Then

    Dim lblqy As Label = DirectCast(e.Row.FindControl("lblqty"), Label)

    Dim qty As Integer = Int32.Parse(lblqy.Text)

    total = total + qty

    End If

    If e.Row.RowType = DataControlRowType.Footer Then

    Dim lblTotalqty As Label = DirectCast(e.Row.FindControl("lblTotalqty"), Label)

    lblTotalqty.Text = total.ToString()

    End If

    End Sub

    End Class


     

    DataGridView cell move Vb.Net

    If e.KeyCode = Keys.Enter Then

                Select Case DataGridView1.CurrentCell.ColumnIndex

                    Case 1

                        If Len(Trim(DataGridView1.CurrentRow.Cells(1).Value)) > 0 Then

                            DataGridView1.CurrentCell = DataGridView1(2, DataGridView1.CurrentCell.RowIndex)

                            DataGridView1.Focus()

                        Else

                            DataGridView1.CurrentCell = DataGridView1(3, DataGridView1.CurrentCell.RowIndex)

                        End If

                    Case 2

                        DataGridView1.CurrentCell = DataGridView1(3, DataGridView1.CurrentCell.RowIndex)

                    Case 3

                        DataGridView1.CurrentCell = DataGridView1(4, DataGridView1.CurrentCell.RowIndex)

                    Case 4

                        DataGridView1.CurrentCell = DataGridView1(5, DataGridView1.CurrentCell.RowIndex)

                    Case 5

                        DataGridView1.CurrentCell = DataGridView1(1, DataGridView1.CurrentCell.RowIndex + 1)

                End Select

            End If

    e.Handled = True

    DataGridView Cell Color Vb.Net

      DataGridView1.GridColor = Color.Red

      DataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None

      DataGridView1.BackgroundColor = Color.LightGray


      DataGridView1.DefaultCellStyle.SelectionBackColor = Color.Red

      DataGridView1.DefaultCellStyle.SelectionForeColor = Color.Yellow


      DataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.[True]


      DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect

      DataGridView1.AllowUserToResizeColumns = False


      DataGridView1.RowsDefaultCellStyle.BackColor = Color.Bisque

      DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige

    Comments

    Popular posts from this blog

    Marg ERP 9+ Shortcut Keys

    Contents Marg ERP 9+ Shortcut Keys           F2        - Sale Bill      Alt+A     - Counter Sale      Alt+P     - Purc.Challan      Alt+S     - Sale Challan      Alt+Ins   - Cash Challan      Ctrl+T/Z  - Copy Bill      Ctrl+F3/F3- Sale Modify      Ctrl+O    - Import/Export      Ctrl+K    - Stock Less      Ctrl+D    - Stock Add      Ctrl+R    - Cash/Cr/Setup      Ctrl+P    - Load PO/PenChall      Ctrl+F9   - Bill-Adjustments      Ctrl+V    - QRID Or...

    Vb.Net and MS-Access database Conection | TechbyMati

    Contents Vb.Net and MS-Access database Conection Open connection to password protected Access database: "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; Jet OLEDB:Database Password=Your_Password" connStr = "Provider=Microsoft.Jet.OLEDB.4.0; " +             "Data Source=G:\\Backup\\Kashif\\xyzDB.mdb";             qryStr = "select content,websiteID  from content";             dbConn = new OleDbConnection(connStr); Examples:      SQL:  "server=tonydev;database=northwind;uid=tony;pwd=hrmmm"               "server=tonydev;database=northwind;trusted_connection=yes"      OLE: "Provider=Microsoft.Jet.OLEDB.4.0; Data source=C:\tony.mdb"     Public Function FetchData(ByVal FileName As String) As DataSet         'Define the connectors   ...

    Marg ERP 9+ Software Download: The Ultimate Guide to GST Billing & Accounting for SMEs (2026)

    Marg ERP 9+ Software Download: The Ultimate Guide to GST Billing & Accounting for SMEs If you run a small or medium-sized enterprise (SME), you already know that managing daily operations can feel like a high-wire balancing act. Between tracking inventory, ensuring accurate billing, managing customer relationships, and staying compliant with ever-changing GST regulations, there is very little room for error. Manual accounting and outdated spreadsheet methods no longer cut it in today’s fast-paced digital economy. Enter Marg ERP 9+ , one of India's most trusted and widely used business management platforms. Whether you are a retail shop owner, a massive FMCG distributor, or a pharmacy handling thousands of complex SKUs, finding the right software is critical to scaling your business. In this comprehensive, SEO-friendly guide, we will dive deep into what Marg Software is, explore its inspiring history, break down its top-tier features, and show you exactly...