Results 1 to 3 of 3

Thread: [RESOLVED] [2005] Data grid view

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Resolved [RESOLVED] [2005] Data grid view

    Hi

    Pls check my code and help how to define the data grid in col.



    Code:
     Private Sub DesignSearchGrid()
            With dgvSearch
                .EditMode = DataGridViewEditMode.EditProgrammatically
                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
                .AllowUserToOrderColumns = True
                .AllowUserToResizeRows = True
                .AllowUserToResizeColumns = True
                .MultiSelect = False
                .RowHeadersVisible = False
                .Location = New Point(9, 43)
                .Size = New Size(266, 177)
                .ColumnCount = 3
                .RowCount = 1
                .Columns(0).Name = "EmpCode"
                .Columns(0).Width = 70
                .Columns(1).Name = "Employee Name"
                .Columns(1).Width = 200
                .Columns(2).Name = "Date of Birth"
                .Columns(2).Width = 100
            End With
        End Sub
    
      Private Sub PopulateSearchGrid()
            Dim DaSearch As SqlDataAdapter
            Dim dtSearch As New DataTable
            Dim StrQuery As String
            Dim iRow As Integer
            Try
                StrQuery = "SELECT EmployeeMaster.EmpCode, EmployeeMaster.Name as EmpName,EmployeeMaster.DOB as EmpName FROM EmployeeMaster"
                DaSearch = New SqlDataAdapter(StrQuery, Conn)
                DaSearch.Fill(dtSearch)
                For iRow = 0 To dgvSearch.RowCount - 1
                    dgvSearch.Rows(iRow).Cells(0).Value = dtSearch.Rows.Item("EmpCode")
                    dgvSearch.Rows(iRow).Cells(0).Value = dtSearch.Rows.Item("EmpName")
                    dgvSearch.Rows(iRow).Cells(0).Value = dtSearch.Rows.Item("DOB")
                Next iRow
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub
    thanks

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: [2005] Data grid view

    Please explain in brief your question.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Data grid view

    Create a DataGridViewColumn of the appropriate type, e.g. DataGridViewTextBoxColumn, then set its properties and add it to the grid's Columns collection.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width