Solved

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

Posted on 2011-09-05
2
295 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 500 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

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
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 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