Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. DATAGRID OF VB.NET 2003 AND 2005

DATAGRID OF VB.NET 2003 AND 2005

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasehelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    klaydze
    wrote on last edited by
    #1

    i am using vb.net 2003 and using datagrid to show my records in my table. after a month i switch to vb.net 2005 and i have problem in the event of double_click of datagridview of vb.net 2005. this is my code in double_click event of vb.net 2003 using datagrid txt1.text=datagrid1.item(datagrid1.currentrowindex,0).tostring this is my code in double_click event of vb.net 2005 using datagridview txt1.text=datagridview1.item(datagridview1.currentrow.index,0).tostring my problem is. when i double click my datagridview in vb.net 2005 the value of my textbox is this "DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=0 }" but in vb.net 2003 is ok. i mean what ever the value of my index 0 in my table that is the value of my textbox. any idea why in vb.net 2005 give me an output like that. thx in advance

    Don't block the drive way of all the newbies in programming. :)

    D 1 Reply Last reply
    0
    • K klaydze

      i am using vb.net 2003 and using datagrid to show my records in my table. after a month i switch to vb.net 2005 and i have problem in the event of double_click of datagridview of vb.net 2005. this is my code in double_click event of vb.net 2003 using datagrid txt1.text=datagrid1.item(datagrid1.currentrowindex,0).tostring this is my code in double_click event of vb.net 2005 using datagridview txt1.text=datagridview1.item(datagridview1.currentrow.index,0).tostring my problem is. when i double click my datagridview in vb.net 2005 the value of my textbox is this "DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=0 }" but in vb.net 2003 is ok. i mean what ever the value of my index 0 in my table that is the value of my textbox. any idea why in vb.net 2005 give me an output like that. thx in advance

      Don't block the drive way of all the newbies in programming. :)

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      The DataGridView is a completely different animal from the old DataGrid in 2003. The Items collection in the DGV returns, as you've found out, a DatGridViewTextBoxCell object, or whatever object type the column is, not the data inside it! To get at the value that's displayed in the cell, you can use one of two things. Either the Value property of the returned DataGridViewTextBoxCell, or the FormattedValue (as displayed in the grid).

      text1.text = dgv1.item(dgv1.currentrow.index,0).Value

      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      H K 2 Replies Last reply
      0
      • D Dave Kreskowiak

        The DataGridView is a completely different animal from the old DataGrid in 2003. The Items collection in the DGV returns, as you've found out, a DatGridViewTextBoxCell object, or whatever object type the column is, not the data inside it! To get at the value that's displayed in the cell, you can use one of two things. Either the Value property of the returned DataGridViewTextBoxCell, or the FormattedValue (as displayed in the grid).

        text1.text = dgv1.item(dgv1.currentrow.index,0).Value

        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        H Offline
        H Offline
        Hansduncan
        wrote on last edited by
        #3

        Along those lines, could you help me out with this code that isn't working the way I want it to. I am trying to insert new row(s) into a datagridview called "CustSalesOpportunityLineDataGridView" (that is databound to a table called "custsalesopportunityline" in a master-detail form that contains includes the header info as well). I have also created a generic product selection form that contains a datagridview called "ArticleDataGridView" that displays all the info and contains the filters that users need to efficiently search and filter out products. The dataset for the "ArticleDataGridView" is based on a view that I have created in the database. On the "ArticleDataGridView" I have created a column called "Select_Article" that is a DataGridViewCheckBoxColumn. (false value = 0, indeterminate = 0, true =1). If the users want to add a particular product to the SalesOpportunityLine datagridview they should be able to check the checkbox for each desired row and then click the AddAndContinueButton. The Select_Article checkbox column is the leftmost column of the datagridview. For each product that they have selected in the articledatagridview a new row in the "CustSalesOpportunityLineDataGridView" should be created and displayed as well as the articleID, name and Salesopportunityheaderid. Where am I going wrong with the code below? Based on the error messages I am getting I don't think it is reading from the correct column. Private Sub AddAndContinueButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddAndContinueButton.Click For Each dgvRow As DataGridViewRow In Me.ArticleDataGridView.SelectedRows If Me.ArticleDataGridView.Item(ArticleDataGridView.CurrentRow.Index, 1).Value = 1 Then Dim dt As DataTable = Me.SalesOpportunity.Tables("custsalesopportunityline") Dim dtRow As DataRow = dt.NewRow() dtRow("Salesopportunityheaderid") = NewSalesOpportunity.SalesoppHeaderID dtRow("articleid") = dgvRow.Cells("ArticleIdDataGridViewTextBoxColumn").Value dtRow("work_articlename") = dgvRow.Cells("ProduktnavnDataGridViewTextBoxColumn").Value dt.Rows.Add(dtRow) End If Next End Sub

        1 Reply Last reply
        0
        • D Dave Kreskowiak

          The DataGridView is a completely different animal from the old DataGrid in 2003. The Items collection in the DGV returns, as you've found out, a DatGridViewTextBoxCell object, or whatever object type the column is, not the data inside it! To get at the value that's displayed in the cell, you can use one of two things. Either the Value property of the returned DataGridViewTextBoxCell, or the FormattedValue (as displayed in the grid).

          text1.text = dgv1.item(dgv1.currentrow.index,0).Value

          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          K Offline
          K Offline
          klaydze
          wrote on last edited by
          #4

          thx for the Info Dave.:)

          Don't block the drive way of all the newbies in programming. :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups