Click here to Skip to main content
15,887,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a winform with a datagridview with a list of date in column 12.
Back end is ms access, I want to click a button and open another form with a list of dates less than current date.I can get form2 open with data but how do I get the less than date?


binding source

C#
dataBaseBindingSource.EndEdit();
               dataBaseTableAdapter.Update(appData.DataBase);
               appData.DataBase.AcceptChanges();
               dataBaseTableAdapter.Fill(appData.DataBase);
               dataGridView1.Refresh();


What I have tried:

lots of inter web search.
I could show code but now were close to working.
Posted
Updated 30-Jan-20 10:20am

1 solution

Define a constructor for form2 accepting the date which will be the upper bound of the data to display. Use this date to populate form's data.

In form1, in the button's click handler, use form2's constructor to pass the desired date.

C#
public class Form2 : Form
{
   private DateTime UpperBound { get; set; }

   public Form2(DateTime date)
   {
      UpperBound = date;
      Build();
   }

   private void Build()
   {
      // Build form's data here using UpperBound property
   }
}

public class Form1 : Form
{
   private void button_Click(object sender, EventArgs e)
   {
      Form2 form = new Form2(DateTime.Today);
      form.Show();
   }
}
 
Share this answer
 
v2
Comments
Member 12349103 30-Jan-20 16:52pm    
Phil.o Do you have an example?
phil.o 30-Jan-20 17:04pm    
Please see my updated answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900