Solved

Form show instead of showmodal, part2

Posted on 2012-04-09
2
215 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
ID: 37824012
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
ID: 37824830
Yes sedgwick that is what I was looking for.

Greetings,

Peter Kiers
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Login 17 51
C# Single Form 8 42
Modal Popup Extender control 1 22
Help with exporting to excel 4 28
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 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