Click here to Skip to main content
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 1: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 OriginalGriff 165
1 Sergey Alexandrovich Kryukov 134
2 Sebastiaan Meijerink 131
3 Rana Waqas 110
4 Maciej Los 84
0 Sergey Alexandrovich Kryukov 6,558
1 OriginalGriff 6,288
2 Peter Leow 2,534
3 Abhinav S 2,358
4 Maciej Los 2,352

Advertise | Privacy | Mobile
Web03 | 2.8.150414.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