Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
AnswerRe: issues concerning c# object reference not set to an instance of an object error Pin
OriginalGriff24-Nov-17 3:11
mveOriginalGriff24-Nov-17 3:11 
GeneralRe: issues concerning c# object reference not set to an instance of an object error Pin
Hervend24-Nov-17 4:34
Hervend24-Nov-17 4:34 
GeneralRe: issues concerning c# object reference not set to an instance of an object error Pin
OriginalGriff24-Nov-17 4:50
mveOriginalGriff24-Nov-17 4:50 
QuestionDisable Update of xmlns into Report Viewer C# Pin
rikidev23-Nov-17 23:37
rikidev23-Nov-17 23:37 
QuestionHow to locate a window by title Pin
Leif Simon Goodwin23-Nov-17 20:53
Leif Simon Goodwin23-Nov-17 20:53 
AnswerRe: How to locate a window by title Pin
Eddy Vluggen24-Nov-17 2:48
professionalEddy Vluggen24-Nov-17 2:48 
GeneralRe: How to locate a window by title Pin
Leif Simon Goodwin24-Nov-17 3:32
Leif Simon Goodwin24-Nov-17 3:32 
QuestionDelete only the rows that has a particular Column value using C# code Pin
Member 1245769023-Nov-17 14:43
Member 1245769023-Nov-17 14:43 
AnswerRe: Delete only the rows that has a particular Column value using C# code Pin
Eddy Vluggen24-Nov-17 2:46
professionalEddy Vluggen24-Nov-17 2:46 
QuestionHow to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201823-Nov-17 14:29
C Sharp coder 201823-Nov-17 14:29 
AnswerRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 2:44
professionalEddy Vluggen24-Nov-17 2:44 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201824-Nov-17 2:56
C Sharp coder 201824-Nov-17 2:56 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 3:06
professionalEddy Vluggen24-Nov-17 3:06 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201824-Nov-17 3:20
C Sharp coder 201824-Nov-17 3:20 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 3:24
professionalEddy Vluggen24-Nov-17 3:24 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201824-Nov-17 3:39
C Sharp coder 201824-Nov-17 3:39 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 3:42
professionalEddy Vluggen24-Nov-17 3:42 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201824-Nov-17 3:52
C Sharp coder 201824-Nov-17 3:52 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 5:10
professionalEddy Vluggen24-Nov-17 5:10 
Member 13515702 wrote:
i'm not perfect the C# code
Yes, well, we all have to start somewhere, and I'm still making foolish mistakes after over 10 years of experience.

You have code in the "Form_Load" event, right? You can put that code into its own method, and than call it from that event. Something like below;

C#
private void Bihourlyforline_Load(object sender, EventArgs e)
{
  this.DoLoad();
}

void DoLoad()
{
// TODO: This line of code loads data into the 'trainningDBDataSetforbihourly1.viewBiHourly3' table. You can move, or remove it, as needed.
this.viewBiHourly3TableAdapter.Fill(this.trainningDBDataSetforbihourly1.viewBiHourly3);
// TODO: This line of code loads data into the 'trainningDBDataSetforbihourly1.tblLine' table. You can move, or remove it, as needed.
this.tblLineTableAdapter.Fill(this.trainningDBDataSetforbihourly1.tblLine);
// TODO: This line of code loads data into the 'trainningDBDataSetforbihourly1.tblLine' table. You can move, or remove it, as needed.
this.tblLineTableAdapter.Fill(this.trainningDBDataSetforbihourly1.tblLine);

this.reportViewer1.RefreshReport();

SetParameters(cbtimeblockline1.Text,cbtimeblockline2.Text,dateTimePicker1forlinebihourly.Text, cbline.Text);
this.reportViewer1.RefreshReport();
}

This way, the "Load_Form" event will just simply call the "DoLoad" method when it needs to populate the tables. Add a button, and an event-handler, and call the method from there too;
C#
public void Button1_Click(object sender, EventArgs e)
{
  this.DoLoad();
}
That would execute the code in the "DoLoad" method if a button is clicked (executing the same lines that you would when you Load_Form).

That is preferred over the alternative, where you raise your "Load_Form" event manually in the OnClick of the button (see below for wrong example);
C#
public void Button1_Click(object sender, EventArgs e)
{
  this.Bihourlyforline_Load(null, EventArgs.Empty);
  // or worse, yet
  this.Bihourlyforline_Load(null, null);
}

Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201828-Nov-17 17:48
C Sharp coder 201828-Nov-17 17:48 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201828-Nov-17 17:56
C Sharp coder 201828-Nov-17 17:56 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen29-Nov-17 0:27
professionalEddy Vluggen29-Nov-17 0:27 
Questionerror:The remote server returned an error: (411) Length Required. Pin
Urmila Pawar22-Nov-17 18:44
Urmila Pawar22-Nov-17 18:44 
AnswerRe: error:The remote server returned an error: (411) Length Required. Pin
Jochen Arndt22-Nov-17 21:28
professionalJochen Arndt22-Nov-17 21:28 
QuestionTabcontrol and treeview data binding Pin
Hervend22-Nov-17 12:59
Hervend22-Nov-17 12:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.