Click here to Skip to main content
11,796,774 members (69,701 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
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:
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 5-Jan-13 0:55am
Richard MacCutchan at 5-Jan-13 7:55am
Please do not post the same question in multiple forums. I have already answered this in the c# forum.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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;
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I solved the problem using following Method populating the form two onload:
Form2 frm2 = new Form2(emriBox.Text, mbiemriBox.Text, xhirollogariaBox.Text, statusi);

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.

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

  Print Answers RSS
0 Maciej Los 480
1 Abhinav S 369
2 OriginalGriff 360
3 CPallini 285
4 KrunalRohit 249
0 OriginalGriff 2,032
1 Maciej Los 1,725
2 KrunalRohit 1,310
3 CPallini 1,055
4 ppolymorphe 883

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100