Click here to Skip to main content
Rate this: bad
good
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
dr_iton640
Comments
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
good
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;
  Permalink  
v2
Rate this: bad
good
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);
                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.
  Permalink  
v2

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

  Print Answers RSS
0 DamithSL 320
1 OriginalGriff 235
2 Afzaal Ahmad Zeeshan 154
3 Sergey Alexandrovich Kryukov 147
4 BillWoodruff 135
0 OriginalGriff 7,510
1 DamithSL 5,494
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2014
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