Click here to Skip to main content
15,912,312 members
Home / Discussions / C#
   

C#

 
GeneralRe: Detecting mouse button that DoubleClick-ed Pin
MoustafaS24-Jun-05 6:36
MoustafaS24-Jun-05 6:36 
GeneralRe: Detecting mouse button that DoubleClick-ed Pin
Luis Alonso Ramos24-Jun-05 8:41
Luis Alonso Ramos24-Jun-05 8:41 
Generalsimple ping class request( non console) Pin
brokenheart23-Jun-05 7:51
brokenheart23-Jun-05 7:51 
GeneralRe: simple ping class request( non console) Pin
Dave Kreskowiak23-Jun-05 9:05
mveDave Kreskowiak23-Jun-05 9:05 
GeneralRe: simple ping class request( non console) Pin
Sebastian Schneider23-Jun-05 22:20
Sebastian Schneider23-Jun-05 22:20 
GeneralRe: simple ping class request( non console) Pin
Dave Kreskowiak24-Jun-05 1:27
mveDave Kreskowiak24-Jun-05 1:27 
GeneralImage Processing Pin
CYMA23-Jun-05 7:19
CYMA23-Jun-05 7:19 
GeneralUpdate datagrid in a MDI child from a MDI child!!!URGENT HELP REQUIRED!!! Pin
GianlucaSeno23-Jun-05 7:09
GianlucaSeno23-Jun-05 7:09 
In brief...I've a MDI application with this MDI childs(at the moment all MDI childs are closed):
1)MDIFORM (MDI container)
2)FORM1 (MDI form child)
3)FORM2 (MDI form child)
I press a menu on MDIFORM that opens FORM1.

In FORM1 there is a texbox.
On keyPress event of textbox I write in a MSAccess table what I'm writing in the textbox.
On Load event of FORM1 I open FORM2 where is a datagrid.
The code is:

public class FORM1: System.Windows.Forms.Form
{
private FORM2 form2=null;
private void FORM1_Load(object sender, System.EventArgs e)
{
if (this.form2==null)
{
this.form2=new FORM2();
this.form2.MdiParent=this.MdiParent;
}
this.form2.Show();
}
private void InsertString(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
// -- INSERT DB
}
}

In FORM2 I've a datagrid where I show results written before in last MSAccess table.The code is this:

public class FORM2 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private System.Windows.Forms.DataGrid dataPreResult;

public FORM2()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataPreResult = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataPreResult)).BeginInit();
this.SuspendLayout();
//
// dataPreResult
//
this.dataPreResult.AllowSorting = false;
this.dataPreResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.dataPreResult.DataMember = "";
this.dataPreResult.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataPreResult.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.dataPreResult.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataPreResult.Location = new System.Drawing.Point(0, 0);
this.dataPreResult.Name = "dataPreResult";
this.dataPreResult.ReadOnly = true;
this.dataPreResult.RowHeaderWidth = 10;
this.dataPreResult.Size = new System.Drawing.Size(232, 613);
this.dataPreResult.TabIndex = 0;
//
// FORM2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(232, 613);
this.Controls.Add(this.dataPreResult);
this.Location = new System.Drawing.Point(600, 10);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FORM2";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Load += new System.EventHandler(this.StringPreResult_Load);
((System.ComponentModel.ISupportInitialize)(this.dataPreResult)).EndInit();
this.ResumeLayout(false);
}
#endregion

public void StringPreResult_Load(object sender, System.EventArgs e)
{
ReadResults();
}

public void ReadResults()
{
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbConnection con =new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
DataTable dt =new DataTable();
dt.Clear();
con.ConnectionString=<connectionstring>;
con.Open();
cmd.Connection = con;
cmd.CommandText = "SELECT * FROM TABLE";

da.SelectCommand = cmd;
da.Fill(dt);

dataPreResult.SetDataBinding(dt,"");

cmd.Cancel();
con.Close();
}

}

So now, my problems is: how can update datagrid in FORM2 from FORM1 when I call keypress event on FORM1 textbox(InsertString in example code)?

Thanks for any help!!!Big Grin | :-D

GeneralRe: Update datagrid in a MDI child from a MDI child!!!URGENT HELP REQUIRED!!! Pin
Bojan Rajkovic23-Jun-05 9:55
Bojan Rajkovic23-Jun-05 9:55 
GeneralRe: Update datagrid in a MDI child from a MDI child!!!URGENT HELP REQUIRED!!! Pin
GianlucaSeno23-Jun-05 10:05
GianlucaSeno23-Jun-05 10:05 
GeneralDateTime.Parse / ParseExact Pin
trevor_moody23-Jun-05 6:32
trevor_moody23-Jun-05 6:32 
GeneralRe: DateTime.Parse / ParseExact Pin
Dave Kreskowiak23-Jun-05 8:58
mveDave Kreskowiak23-Jun-05 8:58 
GeneralTextBox in ASP.NET Pin
BECK723-Jun-05 6:32
BECK723-Jun-05 6:32 
GeneralRe: TextBox in ASP.NET Pin
Dave Kreskowiak23-Jun-05 8:59
mveDave Kreskowiak23-Jun-05 8:59 
GeneralRe: TextBox in ASP.NET Pin
BECK723-Jun-05 9:30
BECK723-Jun-05 9:30 
GeneralRe: TextBox in ASP.NET Pin
DavidNohejl23-Jun-05 9:43
DavidNohejl23-Jun-05 9:43 
GeneralRe: TextBox in ASP.NET Pin
BECK723-Jun-05 11:49
BECK723-Jun-05 11:49 
GeneralRe: TextBox in ASP.NET Pin
DavidNohejl23-Jun-05 11:53
DavidNohejl23-Jun-05 11:53 
GeneralRe: TextBox in ASP.NET Pin
Dave Kreskowiak23-Jun-05 10:10
mveDave Kreskowiak23-Jun-05 10:10 
GeneralRe: TextBox in ASP.NET Pin
BECK723-Jun-05 10:32
BECK723-Jun-05 10:32 
GeneralVARIANT in VC 6.0 and Objects in C# Pin
btanveer23-Jun-05 6:07
btanveer23-Jun-05 6:07 
Generalping class request Pin
brokenheart23-Jun-05 5:53
brokenheart23-Jun-05 5:53 
GeneralRe: ping class request Pin
Simon Wren23-Jun-05 6:05
professionalSimon Wren23-Jun-05 6:05 
GeneralNewbie needs expert help Pin
74Camaro23-Jun-05 4:57
74Camaro23-Jun-05 4:57 
GeneralRe: Newbie needs expert help Pin
V.23-Jun-05 5:03
professionalV.23-Jun-05 5:03 

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.