Click here to Skip to main content
15,886,046 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I created a windows form application. The first form (Form1) holds a ListBos and 5 textboxes. I created a method to show the content of textboxes in a listbox (also i created a text file).
I created also a listbox in Form2 which holds three of textboxes from first Form1.
When i Select a row in listbox from Form1 the content is shown in 5 textboxes with following code:
C#
string linjaListBox = this.ListBox.SelectedItem.ToString();

               string emriPjesa = linjaListBox.Split('\t')[0];
               string mbiemriPjesa = linjaListBox.Split('\t')[1];
               string datelindjaPjesa = linjaListBox.Split('\t')[2];
               string vendlindjaPjesa = linjaListBox.Split('\t')[3];
               string xhirollogariaPjesa = linjaListBox.Split('\t')[4];


               this.emriBox.Text = emriPjesa;
               this.mbiemriBox.Text = mbiemriPjesa;
               this.datelindjaBox.Text = datelindjaPjesa;
               this.vendlindjaBox.Text = vendlindjaPjesa;
               this.xhirollogariaBox.Text = xhirollogariaPjesa;
               indeksLista = Convert.ToInt32(ListBox.SelectedIndex.ToString());


I have the following question?
How to show the content of those emri.Box mbiemri.Box and xhirollogaria.Box that exist in second form (Form2) if I select a row in Listbox from form1.
After that the content of Form2 it must bee written in another text file.
Posted
Comments
Richard MacCutchan 5-Jan-13 7:55am    
Please do not post the same question in multiple forums. I have already answered this in the c# forum.

Hello friend

first you make textbox access specifier as a public of form2

eg : private System.Windows.Forms.TextBox textBox1;
make it
public System.Windows.Forms.TextBox textBox1;

from designer

then create object of form2

ie form2 f2 =new form2();

f2.textBox1 = what you want to display;
 
Share this answer
 
v2
I solved the problem using following Method populating the form two onload:
C#
Form2 frm2 = new Form2(emriBox.Text, mbiemriBox.Text, xhirollogariaBox.Text, statusi);
               frm2.Show();


I wrote this code in Form1.

Thank you for your reply.
P.S. If I have another problem with my software, I'll make a question in this topic.
Cheers.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900