Solved

Form show instead of showmodal, part2

Posted on 2012-04-09
2
211 Views
Last Modified: 2012-04-09
Hi,

I have a mainform called mainForm with a listview on it called lvNotes.
And a second form called StickyNotes. With this code below the user can
not create multiple forms by pressing on the tbNewNote-button. So I have

        private void tbNewNote_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmNote.lblTitle.Text = "";
            frmNote.rtbContent.Clear();
            frmNote.lblCreation.Text = (DateTime.Now.ToString());
            if (frmNote.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ListViewItem myItem = new ListViewItem(frmNote.lblTitle.Text, 0);
                myItem = lvNotes.Items.Add(myItem);
                myItem.SubItems.Add(frmNote.rtbContent.Text);
                myItem.SubItems.Add(frmNote.lblCreation.Text);
                myItem.Selected = true;
            }
        }
        //*------------------------------------------------------------*//
        private void lvNotes_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            frmNote.lblTitle.Text = lvNotes.SelectedItems[0].Text;
            frmNote.rtbContent.Text = lvNotes.SelectedItems[0].SubItems[1].Text;
            frmNote.lblCreation.Text = lvNotes.SelectedItems[0].SubItems[2].Text;
            if (frmNote.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                lvNotes.SelectedItems[0].Text = frmNote.lblTitle.Text;
                lvNotes.SelectedItems[0].SubItems[1].Text = frmNote.rtbContent.Text;
                lvNotes.SelectedItems[0].SubItems[2].Text = frmNote.lblCreation.Text;
            }
        }

Open in new window


So, I have received a super solution from my previous questoin:

        private void tbNewNote_ItemClick(object sender, ItemClickEventArgs e)
        {
            StickyNotes sticky = new StickyNotes();
            sticky.lblTitle.Text = "";
            sticky.rtbContent.Clear();
            sticky.lblCreation.Text = (DateTime.Now.ToString());
            sticky.FormClosed += new FormClosedEventHandler(sticky_FormClosed);
            sticky.Show();
        }
        //*------------------------------------------------------------*//
        void sticky_FormClosed(object sender, FormClosedEventArgs e)
        {
            StickyNotes sticky = (StickyNotes)sender;
            ListViewItem myItem = new ListViewItem(sticky.lblTitle.Text, 0);
            myItem = lvNotes.Items.Add(myItem);
            myItem.SubItems.Add(sticky.rtbContent.Text);
            myItem.SubItems.Add(sticky.lblCreation.Text);
            myItem.Selected = true;
        }

Open in new window


But now I need only the lvNotes_MouseDoubleClick to be changed. That when the
user presses on the listview-row the sticky-form will be displayed with the data
of the row.

Who knows the answer and is willing to help me?

Peter
0
Comment
Question by:peterkiers
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
Comment Utility
can u explain again what exactly you wish to accomplish?
do u need to change only lvNotes_MouseDoubleClick?
do you want the sticky-form to be displayed upon dbl click on the lvNotes list, and pass the sticky-form the selected data?
something like this?

 private void lvNotes_MouseDoubleClick(object sender, MouseEventArgs e)
        {
StickyNotes sticky = new StickyNotes();
            sticky.lblTitle.Text = lvNotes.SelectedItems[0].Text;
sticky.Show();

}

Open in new window

0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
Yes sedgwick that is what I was looking for.

Greetings,

Peter Kiers
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
asp.net mvc5 3 35
.net VBA word safemode 1 23
Converting C# Objects into JSON file 7 35
Closing all open child forms. 4 21
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

5 Experts available now in Live!

Get 1:1 Help Now