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

C#

 
AnswerRe: What type is Control.Anchor ? Pin
sreejith ss nair20-Sep-04 23:24
sreejith ss nair20-Sep-04 23:24 
AnswerRe: What type is Control.Anchor ? Pin
mav.northwind21-Sep-04 1:23
mav.northwind21-Sep-04 1:23 
AnswerRe: What type is Control.Anchor ? Pin
Dave Kreskowiak21-Sep-04 6:53
mveDave Kreskowiak21-Sep-04 6:53 
QuestionHow to access a local variable from out side it's function Pin
Sakkijha20-Sep-04 21:21
Sakkijha20-Sep-04 21:21 
AnswerRe: How to access a local variable from out side it's function Pin
sreejith ss nair20-Sep-04 22:10
sreejith ss nair20-Sep-04 22:10 
GeneralRe: How to access a local variable from out side it's function Pin
Sakkijha20-Sep-04 22:26
Sakkijha20-Sep-04 22:26 
GeneralRe: How to access a local variable from out side it's function Pin
sreejith ss nair20-Sep-04 22:40
sreejith ss nair20-Sep-04 22:40 
GeneralRe: How to access a local variable from out side it's function Pin
Sakkijha20-Sep-04 23:39
Sakkijha20-Sep-04 23:39 
here is my code :

in this code i define a public dataTable "t", but the problem is that i dont want to do that , i want to use the DataTable "test" -which is defined in the addDT() function - in the button1_Click
help me please


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

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

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.TextBox textBox1;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

private DataTable t = 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.button1 = new System.Windows.Forms.Button();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.textBox1 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 80);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// 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, 141);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(432, 136);
this.dataGrid1.TabIndex = 1;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(208, 80);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 2;
this.textBox1.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(432, 277);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.button1);
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 Form1_Load(object sender, System.EventArgs e)
{
addDT();
}

private void addDT()
{
DataTable test = new DataTable();
test.Columns.Add();
dataGrid1.DataSource=test;
t = test;
}

private void button1_Click(object sender, System.EventArgs e)
{
t.Rows.Add(getInput());
}

private string[] getInput()
{
string text = textBox1.Text;
string [] input = new string[] {text};
return input;
}
}
}
GeneralRe: How to access a local variable from out side it's function Pin
sreejith ss nair20-Sep-04 23:51
sreejith ss nair20-Sep-04 23:51 
GeneralRe: How to access a local variable from out side it's function Pin
Sakkijha21-Sep-04 20:40
Sakkijha21-Sep-04 20:40 
GeneralRe: How to access a local variable from out side it's function Pin
Stefan Troschuetz21-Sep-04 4:16
Stefan Troschuetz21-Sep-04 4:16 
QuestionDummies Question: char[] to byte[] Howto? Pin
Ariadne20-Sep-04 20:39
Ariadne20-Sep-04 20:39 
AnswerRe: Dummies Question: char[] to byte[] Howto? Pin
sreejith ss nair20-Sep-04 23:21
sreejith ss nair20-Sep-04 23:21 
AnswerRe: Dummies Question: char[] to byte[] Howto? Pin
ODS21-Sep-04 1:10
ODS21-Sep-04 1:10 
GeneralProblem with Timer Pin
Jo Develper20-Sep-04 20:24
Jo Develper20-Sep-04 20:24 
GeneralRe: Problem with Timer Pin
leppie20-Sep-04 21:20
leppie20-Sep-04 21:20 
GeneralRe: Problem with Timer Pin
Jo Develper21-Sep-04 1:37
Jo Develper21-Sep-04 1:37 
GeneralRe: Problem with Timer Pin
Robert Rohde21-Sep-04 5:20
Robert Rohde21-Sep-04 5:20 
GeneralRe: Problem with Timer Pin
Dave Kreskowiak21-Sep-04 6:25
mveDave Kreskowiak21-Sep-04 6:25 
GeneralRe: Problem with Timer Pin
Robert Rohde21-Sep-04 8:44
Robert Rohde21-Sep-04 8:44 
GeneralRe: Problem with Timer Pin
Dave Kreskowiak21-Sep-04 6:30
mveDave Kreskowiak21-Sep-04 6:30 
GeneralRe: Problem with Timer Pin
Jo Develper21-Sep-04 23:05
Jo Develper21-Sep-04 23:05 
GeneralRe: Problem with Timer Pin
Dave Kreskowiak22-Sep-04 11:53
mveDave Kreskowiak22-Sep-04 11:53 
GeneralRe: Problem with Timer Pin
Jo Develper22-Sep-04 20:10
Jo Develper22-Sep-04 20:10 
GeneralMoving Data Between Tiers Pin
shambho20-Sep-04 19:23
shambho20-Sep-04 19:23 

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.