Click here to Skip to main content
15,910,877 members
Home / Discussions / C#
   

C#

 
GeneralProcessStartInfo Pin
exhaulted22-Sep-04 0:34
exhaulted22-Sep-04 0:34 
GeneralRe: ProcessStartInfo Pin
Heath Stewart22-Sep-04 7:27
protectorHeath Stewart22-Sep-04 7:27 
GeneralRe: ProcessStartInfo Pin
exhaulted22-Sep-04 22:33
exhaulted22-Sep-04 22:33 
QuestionHow to remember selection of user after program is closed? Dynamic properties? Pin
mitreviper22-Sep-04 0:34
mitreviper22-Sep-04 0:34 
AnswerRe: How to remember selection of user after program is closed? Dynamic properties? Pin
exhaulted22-Sep-04 0:43
exhaulted22-Sep-04 0:43 
AnswerRe: How to remember selection of user after program is closed? Dynamic properties? Pin
Philip Fitzsimons22-Sep-04 3:06
Philip Fitzsimons22-Sep-04 3:06 
Questionhow to use sql pane Pin
rofida refat22-Sep-04 0:07
sussrofida refat22-Sep-04 0:07 
GeneralDataTable Access Problem Pin
Sakkijha22-Sep-04 0:02
Sakkijha22-Sep-04 0:02 
i have this code in wich i define a local variable t3 of type DataTable.
i want to overwrite this code so that i get the same output BUT i should not define any Local variable !!!
please help me !!

Hint : DataSet can be added to the solution



using System ;
using System.Drawing ;
using System.Collections ;
using System.ComponentModel ;
using System.Windows.Forms ;
using System.Data ;
using System.Net ;
using System.Net.Sockets ;



namespace AddRowTOGrid
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.TextBox txtSource;
private System.Windows.Forms.DataGrid dataGrid1;

///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;


DataTable t3 = new DataTable();

public Form1()
{




//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

}

///
/// Clean up any resources being used.
///

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

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.btnAdd = new System.Windows.Forms.Button();
this.txtSource = new System.Windows.Forms.TextBox();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// btnAdd
//
this.btnAdd.Location = new System.Drawing.Point(88, 80);
this.btnAdd.Name = "btnAdd";
this.btnAdd.TabIndex = 0;
this.btnAdd.Text = "ADD";
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// txtSource
//
this.txtSource.Location = new System.Drawing.Point(192, 80);
this.txtSource.Name = "txtSource";
this.txtSource.Size = new System.Drawing.Size(104, 20);
this.txtSource.TabIndex = 1;
this.txtSource.Text = "";
this.txtSource.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtSource_KeyPress);
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(0, 165);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.RowHeaderWidth = 32;
this.dataGrid1.Size = new System.Drawing.Size(400, 112);
this.dataGrid1.TabIndex = 2;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(400, 277);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.txtSource);
this.Controls.Add(this.btnAdd);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void btnAdd_Click(object sender, System.EventArgs e)
{

if ( txtSource.Text.ToString()!="")
{
t3.Rows.Add(getSource());
txtSource.Text="";
}
else
MessageBox.Show("Empty Row Can't Be Added");

}
private string[] getSource()
{
string s = txtSource.Text.ToString();
string [] data = new string[]{s} ;
return data ;
}

private void Form1_Load(object sender, System.EventArgs e)
{
AddCR();
}
private void AddCR()
{
DataTable t = new DataTable("Test");
DataRow dtR;
dtR = t.NewRow();
t.Columns.Add();
dataGrid1.DataSource = t ;
t3 = t ;
}


private void txtSource_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if ( e.KeyChar==13 )
if ( txtSource.Text!="")
{
t3.Rows.Add(getSource());
txtSource.Text="";
}
else
MessageBox.Show("Empty Row Can't Be Added");

}

}
}
GeneralRe: DataTable Access Problem Pin
exhaulted22-Sep-04 0:25
exhaulted22-Sep-04 0:25 
GeneralRe: DataTable Access Problem Pin
Sakkijha22-Sep-04 23:00
Sakkijha22-Sep-04 23:00 
GeneralRe: DataTable Access Problem Pin
exhaulted23-Sep-04 0:51
exhaulted23-Sep-04 0:51 
Generalcall to Clarion 5.5 made .dll Pin
BorisKco21-Sep-04 23:53
BorisKco21-Sep-04 23:53 
GeneralSystem.IO.Stream Pin
sachinkalse21-Sep-04 23:15
sachinkalse21-Sep-04 23:15 
GeneralRe: System.IO.Stream Pin
leppie21-Sep-04 23:26
leppie21-Sep-04 23:26 
GeneralRe: System.IO.Stream Pin
Hugo Hallman23-Sep-04 0:13
Hugo Hallman23-Sep-04 0:13 
Generalabout WinForm: How can i build Pin
skywen21-Sep-04 22:29
skywen21-Sep-04 22:29 
Generalc# coordinate system question Pin
I_ID21-Sep-04 22:10
I_ID21-Sep-04 22:10 
GeneralProblems with creating shortcuts on Target PC using the dotnet setup and deployment projects Pin
samirazmat21-Sep-04 18:56
samirazmat21-Sep-04 18:56 
GeneralCapturing HTML as Image Pin
smeese21-Sep-04 18:09
smeese21-Sep-04 18:09 
GeneralRe: Capturing URL as Image Pin
eggie522-Sep-04 18:14
eggie522-Sep-04 18:14 
GeneralRe: Capturing URL as Image Pin
smeese23-Sep-04 2:37
smeese23-Sep-04 2:37 
GeneralThreading Puzzles. Pin
stan2821-Sep-04 15:21
stan2821-Sep-04 15:21 
GeneralRe: Threading Puzzles. Pin
Nick Parker21-Sep-04 17:14
protectorNick Parker21-Sep-04 17:14 
GeneralRe: Threading Puzzles. Pin
stan2822-Sep-04 7:41
stan2822-Sep-04 7:41 
GeneralRe: Threading Puzzles. Pin
stan2823-Sep-04 4:39
stan2823-Sep-04 4:39 

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.