Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

listview

variable type

  • Please log in to reply
13 replies to this topic

#1 Siten0308

Siten0308

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 298 posts

Posted 26 November 2008 - 10:00 AM

Hello,

I am practicing right now using collections, my problem or question, what is the best and easy way to use 2 forms, the main form is going to have the listview, the second form is where you have text boxes that will have the user type in a string and/or int (whatever the variable type be) what you want that will go into its designated column(s) in the main form (form1) listview? and maybe taking it a step further and able to delete from listview? So far many examples are complicated to me (yes sadly i am still a beginner programmer). FYI i am using Visual studio 2008 express, i got the list view and naming down, but I am sure i am over complicating things but a good explanation would really help as well as a simple example that would just need one text box and a listview with one column would help greatly.

Thank you
  • 0

#2 Siten0308

Siten0308

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 298 posts

Posted 26 November 2008 - 02:20 PM

any ideas how to do this using the Dictionary<> collection?
  • 0

#3 acer2004

acer2004

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 29 November 2008 - 04:16 PM

I wanna help you, but i don't think I understand well what you want to do, and what it the main function of the second form
  • 0

#4 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 30 November 2008 - 12:43 PM

Do you know how to use a Ditionary<> collection?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#5 dairyman

dairyman

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 11 December 2008 - 09:54 AM

s...
  • 0

#6 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 11 December 2008 - 10:05 AM

I don't understand you, dariyman.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#7 Siten0308

Siten0308

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 298 posts

Posted 11 December 2008 - 11:15 AM

Hello,

Sorry for the late reply everyone, really i just wanted to know if there is an easier way to import data from one form to another in a list view, example. form1 has listview, form2 has textboxes which the data from the text box will be associated with the columns in the listview in form1. Wondering how that can be accomplished in a easy way, ya actually xav someone shows me how which seemed a little complicated and i did it, but wondering if there is other ways of doing it, or should i stick everything in one form and just call it a day : )

Thanks in advance
  • 0

#8 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 11 December 2008 - 11:40 AM

As long as you have an object reference to the instance of the form from the other, you can always access the members (and hence controls) of the other form.

Form1.cs
Form2 frm;

Button1_Click(EventArgs e, object sender)
{
 frm = new Form2();
 frm.Show();

 //The magic part:
 MessageBox.Show("The textbox in the other form says: " + frm.textBox1.Text);
}

  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#9 Siten0308

Siten0308

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 298 posts

Posted 11 December 2008 - 11:56 AM

Cool got that part thanks Xav but going back to the listview in form1 and textboxes associated in form2, have you or anyone written a simple program using this scenario? if so can ya show me such as post it?
  • 0

#10 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 11 December 2008 - 11:58 AM

What exactly do you want to do? Do you want a modal dialog form to pop up, with textboxes in it? And when you close the window (click "Save" or something), the item is added to the listview?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#11 Siten0308

Siten0308

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 298 posts

Posted 11 December 2008 - 12:57 PM

Exactly : )
  • 0

#12 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 11 December 2008 - 01:03 PM

Well why didn't ya say so then? :D

Form1.cs
Button1_Click(EventArgs e, object sender)
{
  Form2 frm = new Form2();
  if (frm.ShowDialog() != DialogResult.OK) return;
  listView1.Items.Add(frm.textBox1.Text);
}

Tada!
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?





Also tagged with one or more of these keywords: variable type

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download