none
how to print only the displayed data in gridview RRS feed

  • Question

  • hey guys. how do I print only the displayed data in the gridview?  I have this table called land where I search a name and all properties of that person will show in the gridview, but when I print it, the print preview shows that all the data in the table will be printed. How do I print only the items showed in my gridview? I'm using reportviewer. Thanks guys:)
    Saturday, February 16, 2019 7:26 AM

All replies

  • Hi Judzzz,

    I'm afraid you need to provide your code relating to your issue.
    I'd like to modify your code, if possible.

    Regars,

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html

    Saturday, February 16, 2019 9:28 AM
  •        

    Imports MySql.Data.MySqlClient
    Imports Microsoft.Reporting.WinForms
    Public Class printgrid
        Public con As New MySqlConnection
        Private Sub printgrid_Load(sender As Object, e As EventArgs) Handles MyBase.Load

            Me.landTableAdapter.Fill(Me.lisDataSet.land)

            Me.ReportViewer1.RefreshReport()

        End Sub
        Sub reload()
            Dim cmd As MySqlCommand
            Dim adp As New MySqlDataAdapter
            Dim sql As String
            sql = "select * from land where cities = '" & viewmap.TextBox2.Text & "'"
            Try
                Me.lisDataSet.Clear()
                con.Open()
                cmd = New MySqlCommand(sql, con)
                adp.SelectCommand = cmd
                adp.Fill(Me.lisDataSet.land)
                cmd.Dispose()
                adp.Dispose()
                con.Dispose()
            Catch ex As Exception
                con.Close()
                MessageBox.Show(ex.Message)
            End Try
            Me.ReportViewer1.RefreshReport()
        End Sub
        Protected Overrides Sub WndProc(ByRef m As Message)
            Const WM_NCLBUTTONDOWN As Integer = 161
            Const WM_SYSCOMMAND As Integer = 274
            Const HTCAPTION As Integer = 2
            Const SC_MOVE As Integer = 61456

            If (m.Msg = WM_SYSCOMMAND) And (m.WParam.ToInt32() = SC_MOVE) Then
                Return
            End If

            If (m.Msg = WM_NCLBUTTONDOWN) And (m.WParam.ToInt32() = HTCAPTION) Then
                Return
            End If

            MyBase.WndProc(m)
        End Sub
    End Class

    Thursday, February 21, 2019 1:47 AM