Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
AnswerRe: Why my .NET application is crashing?! Pin
Dave Kreskowiak27-Oct-15 2:29
mveDave Kreskowiak27-Oct-15 2:29 
QuestionWorking on multithreading application Pin
Member 1132358526-Oct-15 23:39
Member 1132358526-Oct-15 23:39 
AnswerRe: Working on multithreading application Pin
Daniel Pfeffer27-Oct-15 1:23
professionalDaniel Pfeffer27-Oct-15 1:23 
GeneralRe: Working on multithreading application Pin
BillWoodruff27-Oct-15 3:29
professionalBillWoodruff27-Oct-15 3:29 
GeneralRe: Working on multithreading application Pin
Daniel Pfeffer27-Oct-15 4:05
professionalDaniel Pfeffer27-Oct-15 4:05 
AnswerRe: Working on multithreading application Pin
Foothill27-Oct-15 4:30
professionalFoothill27-Oct-15 4:30 
AnswerRe: Working on multithreading application Pin
Gerry Schmitz27-Oct-15 7:23
mveGerry Schmitz27-Oct-15 7:23 
Questionnew to C# Pin
Member 1206164726-Oct-15 18:39
Member 1206164726-Oct-15 18:39 
Can anyone explain what this code is doing, got this code from codeproject - how this is cponnectipon tpo database?

namespace WindowsFormsApplication2
{
partial class Form1
{
///
/// Required designer variable.
///

private System.ComponentModel.IContainer components = null;

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

/// <param name="disposing" />true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (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.dataGridView1 = new System.Windows.Forms.DataGridView();
this.dataGridView2 = new System.Windows.Forms.DataGridView();
this.cboX = new System.Windows.Forms.ComboBox();
this.cboY = new System.Windows.Forms.ComboBox();
this.cboZ = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.txttNullValue = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.chkSumValues = new System.Windows.Forms.CheckBox();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// dataGridView1
//
this.dataGridView1.AllowUserToOrderColumns = true;
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(0, 23);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(274, 491);
this.dataGridView1.TabIndex = 0;
//
// dataGridView2
//
this.dataGridView2.AllowUserToOrderColumns = true;
this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView2.Location = new System.Drawing.Point(3, 156);
this.dataGridView2.Name = "dataGridView2";
this.dataGridView2.Size = new System.Drawing.Size(284, 355);
this.dataGridView2.TabIndex = 2;
//
// cboX
//
this.cboX.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cboX.FormattingEnabled = true;
this.cboX.Location = new System.Drawing.Point(74, 8);
this.cboX.Name = "cboX";
this.cboX.Size = new System.Drawing.Size(87, 21);
this.cboX.TabIndex = 3;
//
// cboY
//
this.cboY.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cboY.FormattingEnabled = true;
this.cboY.Location = new System.Drawing.Point(74, 35);
this.cboY.Name = "cboY";
this.cboY.Size = new System.Drawing.Size(87, 21);
this.cboY.TabIndex = 4;
//
// cboZ
//
this.cboZ.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cboZ.FormattingEnabled = true;
this.cboZ.Location = new System.Drawing.Point(74, 62);
this.cboZ.Name = "cboZ";
this.cboZ.Size = new System.Drawing.Size(87, 21);
this.cboZ.TabIndex = 5;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 11);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(52, 13);
this.label1.TabIndex = 6;
this.label1.Text = "Column X";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 35);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(52, 13);
this.label2.TabIndex = 7;
this.label2.Text = "Column Y";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(13, 62);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(52, 13);
this.label3.TabIndex = 8;
this.label3.Text = "Column Z";
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(173, 8);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(114, 78);
this.button1.TabIndex = 9;
this.button1.Text = "update";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// splitContainer1
//
this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.splitContainer1.Location = new System.Drawing.Point(12, 15);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.label5);
this.splitContainer1.Panel1.Controls.Add(this.dataGridView1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.label6);
this.splitContainer1.Panel2.Controls.Add(this.chkSumValues);
this.splitContainer1.Panel2.Controls.Add(this.label4);
this.splitContainer1.Panel2.Controls.Add(this.txttNullValue);
this.splitContainer1.Panel2.Controls.Add(this.label1);
this.splitContainer1.Panel2.Controls.Add(this.button1);
this.splitContainer1.Panel2.Controls.Add(this.dataGridView2);
this.splitContainer1.Panel2.Controls.Add(this.label3);
this.splitContainer1.Panel2.Controls.Add(this.cboX);
this.splitContainer1.Panel2.Controls.Add(this.label2);
this.splitContainer1.Panel2.Controls.Add(this.cboY);
this.splitContainer1.Panel2.Controls.Add(this.cboZ);
this.splitContainer1.Size = new System.Drawing.Size(568, 514);
this.splitContainer1.SplitterDistance = 274;
this.splitContainer1.TabIndex = 10;
//
// txttNullValue
//
this.txttNullValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txttNullValue.Location = new System.Drawing.Point(74, 87);
this.txttNullValue.Name = "txttNullValue";
this.txttNullValue.Size = new System.Drawing.Size(87, 20);
this.txttNullValue.TabIndex = 10;
this.txttNullValue.Text = "-";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(13, 87);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(55, 13);
this.label4.TabIndex = 11;
this.label4.Text = "Null Value";
//
// chkSumValues
//
this.chkSumValues.AutoSize = true;
this.chkSumValues.Location = new System.Drawing.Point(74, 113);
this.chkSumValues.Name = "chkSumValues";
this.chkSumValues.Size = new System.Drawing.Size(82, 17);
this.chkSumValues.TabIndex = 13;
this.chkSumValues.Text = "Sum Values";
this.chkSumValues.UseVisualStyleBackColor = true;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(3, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(44, 13);
this.label5.TabIndex = 1;
this.label5.Text = "Source:";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(16, 137);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(40, 13);
this.label6.TabIndex = 14;
this.label6.Text = "Result:";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(592, 541);
this.Controls.Add(this.splitContainer1);
this.Name = "Form1";
this.Text = "Pivot Table";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.DataGridView dataGridView2;
private System.Windows.Forms.ComboBox cboX;
private System.Windows.Forms.ComboBox cboY;
private System.Windows.Forms.ComboBox cboZ;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txttNullValue;
private System.Windows.Forms.CheckBox chkSumValues;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
}
}

namespace PivotTable
{
public partial class Form1 : Form
{
DataTable dt = new DataTable();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
dt.Columns.Add("EmployeeID", Type.GetType("System.String"));
dt.Columns.Add("OrderID", Type.GetType("System.Int32"));
dt.Columns.Add("Amount", Type.GetType("System.Decimal"));
dt.Columns.Add("Cost", Type.GetType("System.Decimal"));
dt.Columns.Add("Date", Type.GetType("System.String"));
dt.Rows.Add(new object[] { "Sam", 1, 25.00, 13.00, "01/10/2007" });
dt.Rows.Add(new object[] { "Sam", 2, 512.00, 1.00, "02/10/2007" });
dt.Rows.Add(new object[] { "Sam", 3, 512.00, 1.00, "03/10/2007" });
dt.Rows.Add(new object[] { "Tom", 4, 50.00, 1.00, "04/10/2007" });
dt.Rows.Add(new object[] { "Tom", 5, 3.00, 7.00, "03/10/2007" });
dt.Rows.Add(new object[] { "Tom", 6, 78.75, 12.00, "02/10/2007" });
dt.Rows.Add(new object[] { "Sue", 7, 11.00, 7.00, "01/10/2007" });
dt.Rows.Add(new object[] { "Sue", 8, 2.50, 66.20, "02/10/2007" });
dt.Rows.Add(new object[] { "Sue", 9, 2.50, 22.00, "03/10/2007" });
dt.Rows.Add(new object[] { "Jack", 10, 6.00, 23.00, "02/10/2007" });
dt.Rows.Add(new object[] { "Jack", 11, 117.00, 199.00, "04/10/2007" });
dt.Rows.Add(new object[] { "Jack", 12, 13.00, 2.60, "01/10/2007" });
dt.Rows.Add(new object[] { "Jack", 13, 11.40, 99.80, "03/10/2007" });
dt.Rows.Add(new object[] { "Phill", 14, 37.00, 2.10, "02/10/2007" });
dt.Rows.Add(new object[] { "Phill", 15, 65.20, 99.30, "04/10/2007" });
dt.Rows.Add(new object[] { "Phill", 16, 34.10, 27.00, "02/10/2007" });
dt.Rows.Add(new object[] { "Phill", 17, 17.00, 959.00, "04/10/2007" });

dataGridView1.DataSource = dt;

foreach (DataColumn dc in dt.Columns)
cboX.Items.Add(dc.ColumnName);
foreach (DataColumn dc in dt.Columns)
cboY.Items.Add(dc.ColumnName);
foreach (DataColumn dc in dt.Columns)
cboZ.Items.Add(dc.ColumnName);
}

private void button1_Click_1(object sender, EventArgs e)
{
try
{
string x = "";
string y = "";
string z = "";

if (cboX.SelectedItem != null)
x = cboX.SelectedItem.ToString();
if (cboY.SelectedItem != null)
y = cboY.SelectedItem.ToString();
if (cboZ.SelectedItem != null)
z = cboZ.SelectedItem.ToString();

DataTable newDt = new DataTable();
if (y != "" && z != "")
newDt = PivotTable.GetInversedDataTable(dt, x, y, z, txttNullValue.Text, chkSumValues.Checked);
else
newDt = PivotTable.GetInversedDataTable(dt, x, y);

dataGridView2.DataSource = newDt;

}
catch(Exception err)
{
MessageBox.Show("Error: " + err.Message);
}

}

}
}
AnswerRe: new to C# Pin
Garth J Lancaster26-Oct-15 19:34
professionalGarth J Lancaster26-Oct-15 19:34 
AnswerRe: new to C# Pin
John Torjo26-Oct-15 19:51
professionalJohn Torjo26-Oct-15 19:51 
AnswerRe: new to C# Pin
OriginalGriff26-Oct-15 22:50
mveOriginalGriff26-Oct-15 22:50 
AnswerRe: new to C# Pin
BillWoodruff27-Oct-15 1:43
professionalBillWoodruff27-Oct-15 1:43 
Questionchart axis offset when reflesh data Pin
smallkubi26-Oct-15 1:29
smallkubi26-Oct-15 1:29 
AnswerRe: chart axis offset when reflesh data Pin
John Torjo26-Oct-15 6:06
professionalJohn Torjo26-Oct-15 6:06 
QuestionI have this code in C # more people basic_info returns 0!? Can someone help me? Pin
Member 1208599525-Oct-15 9:05
Member 1208599525-Oct-15 9:05 
AnswerRe: I have this code in C # more people basic_info returns 0!? Can someone help me? Pin
BillWoodruff25-Oct-15 9:13
professionalBillWoodruff25-Oct-15 9:13 
GeneralRe: I have this code in C # more people basic_info returns 0!? Can someone help me? Pin
Member 1208599525-Oct-15 9:24
Member 1208599525-Oct-15 9:24 
GeneralRe: I have this code in C # more people basic_info returns 0!? Can someone help me? Pin
BillWoodruff25-Oct-15 11:25
professionalBillWoodruff25-Oct-15 11:25 
AnswerRe: I have this code in C # more people basic_info returns 0!? Can someone help me? Pin
Member 1208599525-Oct-15 9:18
Member 1208599525-Oct-15 9:18 
GeneralRe: I have this code in C # more people basic_info returns 0!? Can someone help me? Pin
Member 1208599525-Oct-15 9:23
Member 1208599525-Oct-15 9:23 
GeneralRe: I have this code in C # more people basic_info returns 0!? Can someone help me? Pin
Pete O'Hanlon25-Oct-15 12:06
mvePete O'Hanlon25-Oct-15 12:06 
GeneralRe: I have this code in C # more people basic_info returns 0!? Can someone help me? Pin
Member 1208599525-Oct-15 12:16
Member 1208599525-Oct-15 12:16 
GeneralRe: I have this code in C # more people basic_info returns 0!? Can someone help me? Pin
Pete O'Hanlon25-Oct-15 12:48
mvePete O'Hanlon25-Oct-15 12:48 
GeneralRe: I have this code in C # more people basic_info returns 0!? Can someone help me? Pin
Member 1208599525-Oct-15 13:04
Member 1208599525-Oct-15 13:04 
GeneralRe: I have this code in C # more people basic_info returns 0!? Can someone help me? Pin
Member 1208599525-Oct-15 12:24
Member 1208599525-Oct-15 12:24 

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.