Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Pass text from a textbox on a dialogform to the listview on the main form.

Posted on 2011-09-05
2
Medium Priority
?
300 Views
Last Modified: 2013-12-17
Hi,

I have a main form called MainForm and a dialog form called StickyNotes.

In the close or closing event of the form StickyNotes I want to put this line:

lvNotes.SelectedItems[0].Text = frmNote.textBox1.Text;

But the lvNotes is a listview that resides on the mainform

Who knows the solution?

Peter
0
Comment
Question by:peterkiers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 36485842
Don't try to "push" from StickyNotes to MainForm.

Instead, "pull" from MainForm to StickyNotes.

Since you are displaying StickyNotes as a dialog, MainForm will stop execution until StickyNotes is closed.  Furthermore, MainForm will already have a reference to StickyNotes since that is where it was created.

First you need to change the Modifiers() property of textBox1 on StickyNotes to public.

Afterwards, it would look something like this in MainForm:
public partial class MainForm : Form
    {

        private void btnStickyNotes_Click(object sender, EventArgs e)
        {
            StickyNotes sn = new StickyNotes();
            if (sn.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.lvNotes.SelectedItems[0].Text = sn.textBox1.Text;
            }
        }

    }

Open in new window

0
 
LVL 1

Author Comment

by:peterkiers
ID: 36485867
Thanks.

Peter
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Screencast - Getting to Know the Pipeline

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question