1
Answer

What happen with this message in displaying my report?

Hi Sirs!
 
Could you try to think with me this problem please:
 
I have two forms, on form1 (I use one "textbox1") and on form2 where there is my reportview tool with one "textbox1" also.
Now what I am doing? when I insert for example a name in textbox1 of the form1 and I press on my button to open the form2. Automatically, its transfert the textbox value of form1 to the form2's textbox1. Suddlently its make a filter and previsualize my report. Until there its work perfectly.
But and but when I insert (or write) a name to do the same find its give me this error message: 
Cannot access a disposed object.
Object name: 'ReportViewer'.
Its doesnt give the error message when after to insert a name and show the report. Then when I stop the program and restart... And write other name. Its doesnt give that message. I am not sure if I am clearm with explanation. Have a look:
 
// the first form 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FactuModelo
{
public partial class Facturacao : Form
{
Form2 f2;
public Facturacao()
or
{
InitializeComponent();
}
private void btnPrevisualizar_Click(object sender, EventArgs e)
{
if (f2 == null)
f2 = new Form2();
f2.ValueFromFacturacao(txtbxName.Text);
f2.Show();
}
}
}
 --------------
 //the secong form
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FactuModelo
{
public partial class frmRptFactura : Form
{
public frmRptFactura()
{
InitializeComponent();
}
public void ValueFromFacturacao(string value)
{
textBox1.Text = value;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
this.factura_modeloTableAdapter.Fill(this.DSFactura.factura_modelo, textBox1.Text);
this.reportViewer1.RefreshReport();
}
}
}
 
Answers (1)
0
Roberto Salemi

Roberto Salemi

NA 146 50.4k 9y
Resolved with this code:


<Grid VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Toolbar Command -->
<StackPanel Orientation="Horizontal" Margin="0,0,0,0" Visibility="Visible" Grid.Row="0">
[MY CONTENT]
</StackPanel>

<DataGrid Name="dgSample" Grid.Row="1">
<DataGrid.Columns>
...
</DataGrid.Columns>
        </DataGrid>
</Grid>
0
Sabyasachi Mishra

Sabyasachi Mishra

NA 2.4k 841.3k 9y
Add your datagrid inside ScrollViewerLike
 <ScrollViewer  VerticalScrollBarVisibility="Auto" Height="Auto">
        <DataGrid>
        </DataGrid>
</ScrollViewer >
Avoid uses of Margin and heights if you are using scrollviewer