Solved

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

Posted on 2011-09-05
2
290 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
2 Comments
 
LVL 85

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
c# string handling 1 27
Not showing JavaScript in the list 5 37
Replace &lt; with < 14 55
rest webservice call over https via c# 6 21
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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 Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now