Posts

Showing posts from January, 2014

DataGridView Filter by Multiple Columns

It filters only datatable and datatable's default view. I want to filter my datagridview. Here is my code again             DataSet ds = new DataSet();             SqlConnection conn = new SqlConnection("< >");             conn.Open();             SqlDataAdapter adp = new SqlDataAdapter();             SqlCommand comm = new SqlCommand();                          comm.CommandText = "select name, surname from PERSON";             comm.Connection = conn;             adp.SelectCommand = comm;             DataTable dt = new DataTable("person");             adp.Fill(dt);             ds.Tables.Add(dt);                         bindingSource1.DataSource = ds; //from toolbox             bindingSource1.DataMember = "person";             dataGridView1.DataSource = bindingSource1;

Reference a form from subform in C#.net

You're getting a null because your active form is the one you're in and it is not of type frmMain. (I think you may actually be confusing an active form for a parent form?) There are so may ways to do this. You could make your frmMain a singleton but that's weird and ugly and not recommended of late or you could pass a reference of it to its children somehow. Here's one, simple way: Main Form: public partial class frmMain : Form { public frmMain () { InitializeComponent (); } // Main form private void MainFrm_Load ( object sender , EventArgs e ) { FormOrder frmO = new FormOrder ( this ); // pass a ref of self frmO . Show (); } public void Refresh () { // some action } } Sub Form: public partial class FormOrder : Form { private frmMain _parent ; // create a field that refers to the parent public FormOrder ( frmMain parent ) // mod the
Image
Introduction I have tried to search and download few application but that code is working but there is rare guide available for the setting up the printcontrol and adding code for the method I will try to elaborate as much so any one can easily update code even after latest version of Visual Studio Background Just article you can try to use for the multiline text box or richtextbox control or with just minor tweaks you can use for any custom control too. Using the code First of all I would say down load the source code and I will traverse you across that . Create a Visual Studio WinForms project Place the richtextbox over Form from the toolbox panel  Add (Drag on form) the PrintDialog from the  toolbox => printing panel  on the Form  Add the  PrintDocument  from the   toolbox => printing panel  on the Form  Add the Button. Now your Windows Would look like this: So while setting up property the same event will show there or you can double click on th