Click here to Skip to main content
12,623,484 members (31,399 online)
Rate this:
 
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_iton879
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.
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161128.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2016
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