Mada Black

Mada Black

  • NA
  • 67
  • 3.1k

Convert value From DataGridView to GridView Dev Express

Mar 30 2020 5:16 AM
Hello every one
Please gentelman
How to convert this code with GridView DevExpress
In My Form2 ..
I do my research with TextBox1 and on Click Button1 to display the result with its details in Form1.GridView1
I used this code 
  1.  Sub Show_Details_student_category()  
  2.      Form1.GridControl1.DataSource = Nothing  
  3.      Dim DT As New DataTable  
  4.      Dim DA As New OleDb.OleDbDataAdapter("SELECT * From TableStudent Where StudentCode = '" & Me.TextBox1.Text & "' ", Conne)  
  5.      DA.Fill(DT)  
  6.      If DT.Rows.Count = 0 Then  
  7.          MessageBox.Show("Please check the student number""Avertissement", MessageBoxButtons.OK, MessageBoxIcon.Error)  
  8.      Else  
  9.          Dim DR = DT.Rows(0)  
  10.          Form1.TextBox1.Text = DR!student_code  
  11.          Form1.TextBox2.Text = DR!student_Name  
  12.          Form1.TextBox3.Text = DR!student_surname  
  13.          DA = New OleDb.OleDbDataAdapter("SELECT * From TableStudentCategory Where StudentCategoryCode = '" & Me.TextBox1.Text & "'", Conne)  
  14.          Dim DS As New DataSet  
  15.          DS = New DataSet  
  16.          DA.Fill(DS)  
  17.          DT = DS.Tables(0)  
  18.          For I = 0 To DT.Rows.Count - 1  
  19.   
  20.              'Form1.DataGridView1.Rows.Add()  
  21.              'Form1.DataGridView1.Rows(I).Cells(1).Value = DT.Rows(I).Item("StudentCategoryCode")  
  22.              'Form1.DataGridView1.Rows(I).Cells(2).Value = DT.Rows(I).Item("StudentCategoryMath")  
  23.              'Form1.DataGridView1.Rows(I).Cells(3).Value = DT.Rows(I).Item("StudentCategoryHistory")  
  24.              'Form1.DataGridView1.Rows(I).Cells(4).Value = DT.Rows(I).Item("StudentCategoryLetter")  
  25.   
  26.              Form1.GridView1.AddNewRow()  
  27.   
  28.              Form1.GridView1.SetRowCellValue(I).Item(1).Value = DT.Rows(I)("StudentCategoryCode")  
  29.              Form1.GridView1.SetRowCellValue(I).Item(1).Value = DT.Rows(I)("StudentCategoryMath")  
  30.              Form1.GridView1.SetRowCellValue(I).Cells(2).Value = DT.Rows(I).Item("StudentCategoryHistory")  
  31.              Form1.GridView1.SetRowCellValue(I).Cells(3).Value = DT.Rows(I).Item("StudentCategoryLetter")  
  32.   
  33.          Next  
  34.   
  35.      End If  
  36.      Me.Dispose()  
  37.  End Sub  
  38. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click  
  39.      Show_Details_student_category()  
  40.  End Sub 


 I had errors in these lines :
  1. Form1.GridView1.SetRowCellValue(I).Item(1).Value = DT.Rows(I)("StudentCategoryCode")    
  2. Form1.GridView1.SetRowCellValue(I).Item(1).Value = DT.Rows(I)("StudentCategoryMath")    
  3. Form1.GridView1.SetRowCellValue(I).Cells(2).Value = DT.Rows(I).Item("StudentCategoryHistory")    
  4. Form1.GridView1.SetRowCellValue(I).Cells(3).Value = DT.Rows(I).Item("StudentCategoryLetter"
 Thank you in advance for help
Cordially
M.B
 

Answers (3)