Im trying to retrieve a class for printing I had used a couple of year ago, which aint working now. the class is attached cos its too long to post it here.
can someone help it out with this please.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
GridPrinter = New DataGridPrinter(Me.DataGrid4)
If GridPrinter Is Nothing Then
End If
With GridPrinter
.HeaderText = lblItemsCounted.Text
(Me.ComboBox_ColumnHeaderBrush.SelectedItem, Brush)
.PagesAcross = 1
.PrintDocument.Print()
End With
End Sub
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it!
1. This thread belongs in the VB.NET forum because it has nothing to do with databases. the fact that the data in the grid may have come from a database in the first place is hardly relevant.
2. "It ain't working, please help." What sort of response do you really expect to that? Perhaps an explanation of exactly what you're trying to do, how you're trying to do it and what actually happens might be useful.
3. I assume that this class is from Merrion's CodeBank thread. If that's the case then maybe that would be the place to ask a question about it first.
Warning 1 Function 'GetColumnHeadingText' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. C:\Visual Studio 2005..............\DataGridPrinter.vb
------------------------------------------
any help?
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it!
1. My guess is that the code is casting, either implicitly or explicitly, the DataSource of the grid as type DataTable. If you've bound a DataSet and set the DataMember rather than binding a DataSet then you'll have to adjust the code accordingly. Perhaps adjusting the printing class to handle either, and perhaps a BindingSource too, would be the way to go.
2. Easy fixed. Just read the code and edit to make sure that a value is always returned by the method. The best way to do that is to have one and only one Return statement at the very end of the method. You return a local variable that you have set at one or more points within the method. If it's OK to return Nothing then you should initialise that variable to Nothing. If it's not OK to return Nothing then you need to make sure that, no matter what path execution takes through the method, a value will always be assigned to that variable.
Is there a way I can solve this printing problem please
Code:
Warning 2 Function without an 'As' clause; return type of Object assumed. C:\DataGridPrinter_src\DataGridPrinter\DataGridPrinter.vb 410 21 DataGridPrinter
Warning 3 Unused local variable: 'x'. C:\DataGridPrinter_src\DataGridPrinter\DataGridPrinter.vb 419 13 DataGridPrinter
Warning 4 Unused local variable: 'y'. C:\DataGridPrinter_src\DataGridPrinter\DataGridPrinter.vb 419 26 DataGridPrinter
Warning 5
Function 'DrawCellString' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. C:\DataGridPrinter_src\DataGridPrinter\DataGridPrinter.vb 441 5 DataGridPrinter
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it!
Many thanks for your code. The code you sent me works fine on its own except for a small error on the showdialog which Ive fixed. However since I am using Datasets and Dataviews it doesnt work on mine.
Can you fix it for me please to work on both of these. It'spretty urgent cos I need to send this project by tomorrow. Much aqppreciated if you can help.
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it!
My databinding is done this way. The printing is being activiated but it needs to output through a table as the specifications in the class of .Paul above goes.
Does anybody knows how I can alter either the class or this method to print please.
Code:
sing cmd As New SqlClient.SqlCommand(query, MyConn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@success", SqlDbType.Int)
cmd.Parameters("@success").Direction = ParameterDirection.Output
cmd.Parameters.AddWithValue("@startDate", DateTimePicker2.Value.Date)
cmd.Parameters.AddWithValue("@endDate", DateTimePicker1.Value.Date)
MyConn.Open()
Using mMySqlDataAdapter As New SqlClient.SqlDataAdapter(cmd)
Using mDataSet As New DataSet
mDataSet.Clear()
mMySqlDataAdapter.Fill(mDataSet, "tb_LAbook")
mDataView = New DataView
mDataView.Table = mDataSet.Tables("tb_LAbook")
lblNo.Text = mDataView.Count
End Using
End Using
End Using
With DataGrid5
.DataSource = mDataView
' .AutoResizeRows() ' resize columnsfor user resizing facility
End With
Last edited by angelica; Oct 6th, 2008 at 12:30 AM.
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it!