Witam,
Od niedawna bawie sie w Visual Studio 2005. Mamy zrobic projekcik stacji benzynowej i mam pewien kłopot.
A mianowicie chce zrobić tak aby tekst wpisany w textboxie1 na np. form1, zostal przeniesiony do textboxu2 w form2 jak sie cos zrobi(np wybierze jakas opcje w comboboxie w form2).
Wkleje tutaj kod obu formow.
form1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace Orlen
{
public partial class dystrybutor : UserControl
{
public static List<dystrybutor> lista_dystrybutorow = new List<dystrybutor>();
Boolean Status = false;
static int numer_dystrybutora=0;
double kwota;
double WKwota
{
get
{
return kwota;
}
set
{
textBox3.Text=value.ToString();
kwota=value;
}
}
public string numerek_dystrybutora;
public string cenkaa;
double ile_pobrano=0.00;
double Wile_pobrano
{
get
{
return ile_pobrano;
}
set
{
textBox2.Text = value.ToString();
WKwota = value * PodlaczonyZbiornik.cena;
ile_pobrano = value;
}
}
Timer silnik;
double wydajnosc;
zbiornik PodlaczonyZbiornik;
void podlacz_zbiornik(object kto, System.EventArgs e)
{
foreach(zbiornik zb in zbiornik.lista_zbiornikow)
{
if (zb.rodzaj_paliwa == comboBox1.Text)
{
PodlaczonyZbiornik = zb;
textBox1.Text = zb.cena.ToString();
}
}
}
public dystrybutor()
{
InitializeComponent();
dystrybutor.numer_dystrybutora += 1;
lista_dystrybutorow.Add(this);
this.label1.Text = "dystrybutor nr:" + lista_dystrybutorow.Count.ToString();
button1.Click += new EventHandler(wlacz);
button2.Click+=new EventHandler(uruchom_dystrybutor);
comboBox1.Click+=new EventHandler(podlacz_zbiornik);
silnik = new Timer();
silnik.Interval = 100;
silnik.Tick += new EventHandler(lej_paliwo);
numerek_dystrybutora = this.label1.Text;
cenkaa = this.textBox3.Text;
czytaj_zbiorniki();
foreach (Kasa kas in Kasa.lista_kas)
{
kas.czytaj_dystrybutory();
}
}
public void czytaj_zbiorniki()
{
comboBox1.Items.Clear();
foreach (zbiornik zb in zbiornik.lista_zbiornikow)
{
if (zb.rodzaj_paliwa != null)
comboBox1.Items.Add(zb.rodzaj_paliwa);
}
}
form2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;namespace Orlen
{
public partial class Kasa : UserControl
{
public static List<Kasa> lista_kas=new List<Kasa>();
static int numer_kasy = 0;dystrybutor podlaczonyDystrybutor; void podlacz_dystrybutor(object kto, System.EventArgs e) { foreach (dystrybutor zb in dystrybutor.lista_dystrybutorow) { if (zb.numerek_dystrybutora==comboBox1.Text) { podlaczonyDystrybutor = zb; } } foreach (dystrybutor zb in dystrybutor.lista_dystrybutorow) { if (zb.cenkaa == textBox3.Text) { podlaczonyDystrybutor = zb; } } } public Kasa() { InitializeComponent(); Kasa.numer_kasy += 1; lista_kas.Add(this); this.label1.Text = "Kasa nr:" + lista_kas.Count.ToString(); czytaj_dystrybutory(); } public void czytaj_dystrybutory() { comboBox1.Items.Clear(); foreach (dystrybutor zb in dystrybutor.lista_dystrybutorow) ///<b>to dziala i ladnie sie wyswetla</b> { if (zb.numerek_dystrybutora != null) comboBox1.Items.Add(zb.numerek_dystrybutora); } foreach (dystrybutor zb in dystrybutor.lista_dystrybutorow) /////<b>to juz neistety nie dziala</b> { if (zb.cenkaa != null) textBox3.Text = (zb.cenkaa); } } } }
czy ktos wie jak zrobic by dane z cenkaa wyswietlaly sie takze w textboxie?</b>