Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pomoc oko malog programa u C#
Author Message
pubps Offline
Novi korisnik
*

Posts: 5
Joined: Mar 2011
Reputation: 0
Post: #1
Pomoc oko malog programa u C#
gde gresim i sta je u pitanju....pomoc

Ovo je pisano u VS C# 2008...



using System;
using System.Windows.Forms;

public class frmMain : Form
{
private Label label2;
private Label label3;
private Label Label4;
private Label label5;
private TextBox txtName;
private TextBox txtAdress;
private TextBox txtCity;
private TextBox txtState;
private TextBox txtZip;
private TextBox txtResult;
private Button btnDisplayOutput;
private Button btnExit;
private Label label1;
#region Windowscode
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.Label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.txtAdress = new System.Windows.Forms.TextBox();
this.txtCity = new System.Windows.Forms.TextBox();
this.txtState = new System.Windows.Forms.TextBox();
this.txtZip = new System.Windows.Forms.TextBox();
this.txtResult = new System.Windows.Forms.TextBox();
this.btnDisplayOutput = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label1.Location = new System.Drawing.Point(13, 18);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(75, 20);
this.label1.TabIndex = 0;
this.label1.Text = "Name:";
//
// label2
//
this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label2.Location = new System.Drawing.Point(13, 55);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(75, 20);
this.label2.TabIndex = 1;
this.label2.Text = "Adress:";
//
// label3
//
this.label3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label3.Location = new System.Drawing.Point(13, 97);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(75, 20);
this.label3.TabIndex = 2;
this.label3.Text = "City";
//
// Label4
//
this.Label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Label4.Location = new System.Drawing.Point(12, 137);
this.Label4.Name = "Label4";
this.Label4.Size = new System.Drawing.Size(75, 20);
this.Label4.TabIndex = 3;
this.Label4.Text = "State";
//
// label5
//
this.label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label5.Location = new System.Drawing.Point(12, 181);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(75, 20);
this.label5.TabIndex = 4;
this.label5.Text = "Zip";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(127, 18);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(142, 20);
this.txtName.TabIndex = 5;
//
// txtAdress
//
this.txtAdress.Location = new System.Drawing.Point(126, 55);
this.txtAdress.Name = "txtAdress";
this.txtAdress.Size = new System.Drawing.Size(143, 20);
this.txtAdress.TabIndex = 6;
//
// txtCity
//
this.txtCity.Location = new System.Drawing.Point(125, 99);
this.txtCity.Name = "txtCity";
this.txtCity.Size = new System.Drawing.Size(143, 20);
this.txtCity.TabIndex = 7;
//
// txtState
//
this.txtState.Location = new System.Drawing.Point(126, 137);
this.txtState.Name = "txtState";
this.txtState.Size = new System.Drawing.Size(139, 20);
this.txtState.TabIndex = 8;
//
// txtZip
//
this.txtZip.Location = new System.Drawing.Point(125, 181);
this.txtZip.Name = "txtZip";
this.txtZip.Size = new System.Drawing.Size(140, 20);
this.txtZip.TabIndex = 9;
//
// txtResult
//
this.txtResult.Location = new System.Drawing.Point(13, 232);
this.txtResult.Multiline = true;
this.txtResult.Name = "txtResult";
this.txtResult.ReadOnly = true;
this.txtResult.Size = new System.Drawing.Size(254, 39);
this.txtResult.TabIndex = 10;
//
// btnDisplayOutput
//
this.btnDisplayOutput.Location = new System.Drawing.Point(19, 303);
this.btnDisplayOutput.Name = "btnDisplayOutput";
this.btnDisplayOutput.Size = new System.Drawing.Size(51, 21);
this.btnDisplayOutput.TabIndex = 11;
this.btnDisplayOutput.Text = "&Display";
this.btnDisplayOutput.UseVisualStyleBackColor = true;
this.btnDisplayOutput.Click += new System.EventHandler(this.btnDisplayOutput_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(183, 304);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(52, 19);
this.btnExit.TabIndex = 12;
this.btnExit.Text = "E&xit";
this.btnExit.UseVisualStyleBackColor = true;
//
// frmMain
//
this.ClientSize = new System.Drawing.Size(292, 338);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnDisplayOutput);
this.Controls.Add(this.txtResult);
this.Controls.Add(this.txtZip);
this.Controls.Add(this.txtState);
this.Controls.Add(this.txtCity);
this.Controls.Add(this.txtAdress);
this.Controls.Add(this.txtName);
this.Controls.Add(this.label5);
this.Controls.Add(this.Label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "frmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Mailing Label program";
this.ResumeLayout(false);
this.PerformLayout();

}
#endregion

public frmMain()
{
InitializeComponent();
}
public static void Main()
{
frmMain main = new frmMain();
Application.Run(main);
}

private void btnDisplayOutput_Click(object sender, EventArgs e)
{
String buffer;

buffer = "Mailing Label:" + Environment.NewLine +
Environment.NewLine;
buffer = buffer + " Name: " + txtName.Text +
Environment.NewLine;
buffer = buffer + " Adress: " + txtAdress.Text +
Environment.NewLine;
buffer = buffer + " City " + txtCity.Text +
Environment.NewLine;
buffer = buffer + " State " + txtState.Text +
Environment.NewLine;
buffer = buffer + " Zip " + txtZip.Text +
Environment.NewLine;
txtDisplayOutput.Text = buffer;
}
}



i dole u greskama mi prijavljuje sledecu gresku:


Error 1 The name 'txtDisplayOutput' does not exist in the current context 196 9 MailingLabel....to je ovaj zadnji red...

ako umesto txtDisplayOutput.Text = buffer; stavim txtResult.Text = buffer; program se pokrene ali mi se u mailing listi ispisuje samo Mailing Label: i nista vise, iako sam upisao i ime i prezime, i adresu...itd...trebao bi da izbaci u textbox-u sve podatke a ne samo naslov....


HVALA UNAPRED
25-03-2011 03:14 PM
Find all posts by this user Quote this message in a reply
kecko Offline
Forumaš
***

Posts: 645
Joined: Nov 2009
Reputation: 20
Post: #2
RE: Pomoc oko malog programa u C#
Ubuduće bi te zamolio da koristiš code tag
Code:
if(a==b)
{
doSomething();
}
Inače bez puno gledanja koda odmah ti velim da ti txtDisplayOutput uopće ne postoji.
Ovo
Code:
buffer = buffer + " Name: " + txtName.Text +
možeš pisati i ovako
Code:
buffer += " Name: " + txtName.Text +

A da bi bio siguran što ti sadrži buffer na kraju umjesto ovog (zadnja linija)
Code:
txtDisplayOutput.Text = buffer;
stavi ovo
Code:
MessageBox.Show(buffer);
25-03-2011 03:34 PM
Find all posts by this user Quote this message in a reply
pubps Offline
Novi korisnik
*

Posts: 5
Joined: Mar 2011
Reputation: 0
Post: #3
RE: Pomoc oko malog programa u C#
Hvala puno ali meni sad otvara nov prozor u kome ispisuje podatke a trebalo bi u postojecem da ih ispise
(This post was last modified: 25-03-2011 03:41 PM by pubps.)
25-03-2011 03:37 PM
Find all posts by this user Quote this message in a reply
kecko Offline
Forumaš
***

Posts: 645
Joined: Nov 2009
Reputation: 20
Post: #4
RE: Pomoc oko malog programa u C#
Znam ovo je samo provjera da vidimo dal su podaci ok, sad se idemo bavit prikazom, uglavnom prikazuje ti samo prvu liniju točno?
25-03-2011 04:01 PM
Find all posts by this user Quote this message in a reply
pubps Offline
Novi korisnik
*

Posts: 5
Joined: Mar 2011
Reputation: 0
Post: #5
RE: Pomoc oko malog programa u C#
Tacno tako....usput, primer je iz knjige beginning C# by Jack Purdum
(This post was last modified: 25-03-2011 04:07 PM by pubps.)
25-03-2011 04:05 PM
Find all posts by this user Quote this message in a reply
pubps Offline
Novi korisnik
*

Posts: 5
Joined: Mar 2011
Reputation: 0
Post: #6
RE: Pomoc oko malog programa u C#
Pronasao sam u cemu je problem...textbox je bio mali i kada sam ga povecao onda su se prikazali svi podaci...hvala svima na trudu....mada ne znam kako da definisem button Exit da izvrsi komandu tj. da ugasi prozor kad kliknem na Exit
(This post was last modified: 25-03-2011 05:23 PM by pubps.)
25-03-2011 05:22 PM
Find all posts by this user Quote this message in a reply
pubps Offline
Novi korisnik
*

Posts: 5
Joined: Mar 2011
Reputation: 0
Post: #7
RE: Pomoc oko malog programa u C#
nadjoh kako...samo sam trebao staviti this.Close(); ...hvala puno
25-03-2011 06:06 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)