|  |  | 
          
            | คือ โค้ดปุ้ม ค้นหา เมื่อค้นหาเสร็จเเล้ว คลิ้กที grid view ข้อมูลที่ เรคคอร์ด gridview เเล้วมาโชว์ที่ picturebox ที่เเสดงเป็นรูปภาพอีกฟอร์ม หนึ่งครับ 
 เเต่ตอนนี้ทำได้เเต่เป็น textbox ตรงภาพยังไม่ได้ครับ
 
 
 
  Code (VB.NET) 
 Imports System.Data.SqlClient
Public Class search_land
    Dim Conn As SqlConnection = New SqlConnection
    Dim ds As New DataSet
    Dim da As SqlDataAdapter
    Private Property ShowPosition As String
    Private Sub btnsearch_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
        'If MsgBox("คุณต้องการค้นหาข้อมูลใช่หรือไม่ ?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "ค้นหาข้อมูล") = MsgBoxResult.Ok Then
        Try
            ds.Tables.Clear()
            Dim ra As String = ""
            If RadioButton1.Checked Then
                'Me.Label1.Text = "ตามรหัส"
                ra = "LANDID"
            End If
            If RadioButton2.Checked Then
                ra = "PARCEL_CODE"
            End If
            If TextBox4.Text = "" Then
                MsgBox("กรุณากรอกข้อมูลที่ต้องการค้นหา", MsgBoxStyle.Information)
                Me.Close()
            Else
                Dim strConn As String
                strConn = "Data Source=.\SQLEXPRESS;Initial Catalog=SSPEGIS;Integrated Security=True"
                With Conn
                    If .State = ConnectionState.Open Then .Close() 'ถ้าเปิดอยู่ให้ปิดการเชื่อมต่อ Connection ก่อน
                    .ConnectionString = strConn                    ' กำหนดรูปแบบและฐานข้อมูลสำหรับการติดต่อ
                    .Open()                                        'ทำการติดต่อฐานข้อมูล
                End With
                Dim sql As String = "Select*from land where " & ra & " like '" & TextBox4.Text & "%'"
                da = New SqlDataAdapter(sql, Conn)
                da.Fill(ds, "land")
                myGridView.DataSource = ds.Tables("land")
                TextBox4.Clear()
            End If
            ' If dgv1.DataSource = "" Then
            'MsgBox("iiii")
            ' End If
        Catch ex As Exception
            MessageBox.Show(ex.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        ' End If
        Dim cs As New DataGridViewCellStyle
        cs.Font = New Font("ms sans serif", 10, FontStyle.Regular)
        cs.Alignment = DataGridViewContentAlignment.MiddleCenter
        cs.ForeColor = Color.Blue
        With myGridView
            .ColumnHeadersDefaultCellStyle = cs
            .Columns(0).HeaderText = "PID"
            .Columns(1).HeaderText = "รหัสภาษี"
            .Columns(2).HeaderText = "รหัสเเผนที่"
            .Columns(0).Width = 180
            .Columns(1).Width = 140
            .Columns(2).Width = 100
            .Columns(0).SortMode = DataGridViewColumnSortMode.NotSortable
            .Columns(1).SortMode = DataGridViewColumnSortMode.NotSortable
            .Columns(2).SortMode = DataGridViewColumnSortMode.NotSortable
        End With
    End Sub
    Private Sub dgv_CellMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles myGridView.CellMouseUp
        If e.RowIndex = -1 Then Exit Sub
        With myGridView
            frmland.txtLANDID.Text = .Rows.Item(e.RowIndex).Cells(0).Value.ToString()
            frmland.txtPARCEL_CODE.Text = .Rows.Item(e.RowIndex).Cells(1).Value.ToString()
            frmland.txtPICTURE_CODE.Text = .Rows.Item(e.RowIndex).Cells(2).Value.ToString()
            frmland.txtUTM_CODE.Text = .Rows.Item(e.RowIndex).Cells(21).Value.ToString()
            frmland.txtUTM_NO.Text = .Rows.Item(e.RowIndex).Cells(23).Value.ToString()
            frmland.txtUTM_NO_P.Text = .Rows.Item(e.RowIndex).Cells(22).Value.ToString()
            frmland.txtUTM_RATIO.Text = .Rows.Item(e.RowIndex).Cells(20).Value.ToString()
            frmland.txtLDOC_NO.Text = .Rows.Item(e.RowIndex).Cells(19).Value.ToString()
            frmland.txtTAXRATE.Text = .Rows.Item(e.RowIndex).Cells(39).Value.ToString()
            frmland.txtEXTENUATE.Text = .Rows.Item(e.RowIndex).Cells(40).Value.ToString()
            frmland.txtSURVEY_NO.Text = .Rows.Item(e.RowIndex).Cells(26).Value.ToString()
            frmland.txtLAND_NO.Text = .Rows.Item(e.RowIndex).Cells(25).Value.ToString()
            frmland.txtDOL_RAI.Text = .Rows.Item(e.RowIndex).Cells(27).Value.ToString()
            frmland.txtDOL_NGAN.Text = .Rows.Item(e.RowIndex).Cells(28).Value.ToString()
            frmland.txtDOL_WA.Text = .Rows.Item(e.RowIndex).Cells(29).Value.ToString()
            frmland.txtTAXED_RAI.Text = .Rows.Item(e.RowIndex).Cells(39).Value.ToString()
            frmland.txtTAXED_NGAN.Text = .Rows.Item(e.RowIndex).Cells(40).Value.ToString()
            frmland.txtTAXED_WA.Text = .Rows.Item(e.RowIndex).Cells(41).Value.ToString()
            frmland.PictureBox1.Text = ShowPosition()   '''''''''''''''''''''''''''''''''''''''''''''''''  ตรงนีเเหละครับไม่ได้
            frmland.txtTAMBON_TH.Text = .Rows.Item(e.RowIndex).Cells(16).Value.ToString()
            frmland.txtDISTRICT_TH.Text = .Rows.Item(e.RowIndex).Cells(17).Value.ToString()
            frmland.txtPROVINCE_TH.Text = .Rows.Item(e.RowIndex).Cells(18).Value.ToString()
            If .Rows.Item(e.RowIndex).Cells(8).Value.ToString() = "01" Then
                frmland.cboLDOC_TYPE.Text = "โฉนด"
            ElseIf .Rows.Item(e.RowIndex).Cells(8).Value.ToString() = "02" Then
                frmland.cboLDOC_TYPE.Text = "นส.3ก"
            ElseIf .Rows.Item(e.RowIndex).Cells(8).Value.ToString() = "03" Then
                frmland.cboLDOC_TYPE.Text = "นส.3"
            ElseIf .Rows.Item(e.RowIndex).Cells(8).Value.ToString() = "04" Then
                frmland.cboLDOC_TYPE.Text = "สค.1"
            ElseIf .Rows.Item(e.RowIndex).Cells(8).Value.ToString() = "05" Then
                frmland.cboLDOC_TYPE.Text = "ภบท.5"
            ElseIf .Rows.Item(e.RowIndex).Cells(8).Value.ToString() = "06" Then
                frmland.cboLDOC_TYPE.Text = "สทก"
            ElseIf .Rows.Item(e.RowIndex).Cells(8).Value.ToString() = "07" Then
                frmland.cboLDOC_TYPE.Text = "ส.ป.ก.4-01"
            ElseIf .Rows.Item(e.RowIndex).Cells(8).Value.ToString() = "08" Then
                frmland.cboLDOC_TYPE.Text = "น.ค.3"
            ElseIf .Rows.Item(e.RowIndex).Cells(8).Value.ToString() = "99" Then
                frmland.cboLDOC_TYPE.Text = "อื่นๆ"
            End If
            'comboboxการใช้ประโยชน์
            If .Rows.Item(e.RowIndex).Cells(32).Value.ToString() = "01" Then
                frmland.cboLAND_USE.Text = "อยู่อาศัย"
            ElseIf .Rows.Item(e.RowIndex).Cells(32).Value.ToString() = "02" Then
                frmland.cboLAND_USE.Text = "ประกอบการค้า"
            ElseIf .Rows.Item(e.RowIndex).Cells(32).Value.ToString() = "03" Then
                frmland.cboLAND_USE.Text = "เลี้ยงสัตว์"
            ElseIf .Rows.Item(e.RowIndex).Cells(32).Value.ToString() = "04" Then
                frmland.cboLAND_USE.Text = "ปลูกไม้ล้มลุก"
            ElseIf .Rows.Item(e.RowIndex).Cells(32).Value.ToString() = "05" Then
                frmland.cboLAND_USE.Text = "ปลูกไม้ยืนต้น"
            ElseIf .Rows.Item(e.RowIndex).Cells(32).Value.ToString() = "06" Then
                frmland.cboLAND_USE.Text = "ว่างเปล่า"
            ElseIf .Rows.Item(e.RowIndex).Cells(32).Value.ToString() = "07" Then
                frmland.cboLAND_USE.Text = "สาธารณประโยชน์"
            ElseIf .Rows.Item(e.RowIndex).Cells(32).Value.ToString() = "08" Then
                frmland.cboLAND_USE.Text = "ราชการ"
            ElseIf .Rows.Item(e.RowIndex).Cells(32).Value.ToString() = "09" Then
                frmland.cboLAND_USE.Text = "อื่นๆ"
            End If
            'combobox  ทำเลพื้นที่ภาษี
            If .Rows.Item(e.RowIndex).Cells(4).Value.ToString() = "01" Then
                frmland.cboAREATAX.Text = "พื้นที่ 1"
            ElseIf .Rows.Item(e.RowIndex).Cells(4).Value.ToString() = "02" Then
                frmland.cboAREATAX.Text = "พื้นที่ 2"
            ElseIf .Rows.Item(e.RowIndex).Cells(4).Value.ToString() = "03" Then
                frmland.cboAREATAX.Text = "พื้นที่ 3"
            ElseIf .Rows.Item(e.RowIndex).Cells(4).Value.ToString() = "04" Then
                frmland.cboAREATAX.Text = "พื้นที่ 4"
            ElseIf .Rows.Item(e.RowIndex).Cells(4).Value.ToString() = "05" Then
                frmland.cboAREATAX.Text = "พื้นที่ 5"
            End If
            If .Rows.Item(e.RowIndex).Cells(5).Value.ToString() = "01" Then
                frmland.cboEXTENID.Text = "ลดหย่อน รูปแบบที่ 1"
            ElseIf .Rows.Item(e.RowIndex).Cells(5).Value.ToString() = "02" Then
                frmland.cboEXTENID.Text = "ไม่ลดหย่อน"
            End If
            If .Rows.Item(e.RowIndex).Cells(31).Value.ToString() = "1" Then
                frmland.RadioButton1.Checked = "1"
            ElseIf .Rows.Item(e.RowIndex).Cells(31).Value.ToString() = "2" Then
                frmland.RadioButton2.Checked = "2"
            End If
        End With
        Me.Close()
    End Sub
End Class
 
 
 Tag : .NET, Ms SQL Server 2008, Win (Windows App), VB.NET, VS 2010 (.NET 4.x)
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2011-03-15 22:39:42 | By :
                          pisansri | View :
                          2158 | Reply :
                          14 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |