Single Column, Singleton Mode

Source: Internet
Author: User

Single Column, Singleton Mode

Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Linq;
Using System. Runtime. Remoting. Services;
Using System. Text;
Using System. Text. RegularExpressions;
Using System. Threading. Tasks;
Using System. Windows. Forms;

Namespace Day10_0200 Singleton
{
Public partial class FrmPlay: Form
{
Public static FrmPlay OnlyOneForm;
// 1. construct private
Private FrmPlay ()
{
InitializeComponent ();
}

Public string path;
Private void FrmPlay_Load (object sender, EventArgs e)
{

}

Public void PlaySong ()
{
Player1.URL = path;
}


// Static method
Public static FrmPlay GetInstance ()
{
If (OnlyOneForm = null)
{
OnlyOneForm = new FrmPlay ();
Return OnlyOneForm;
}
Else
{
Return OnlyOneForm;
}

}
}
}

 

 

Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Linq;
Using System. Text;
Using System. Threading. Tasks;
Using System. Windows. Forms;

Namespace Day10_0200 Singleton
{
Public partial class FrmList: Form
{
Public FrmList ()
{
InitializeComponent ();
}

Private void FrmList_Load (object sender, EventArgs e)
{
// Select the entire row
DgvList. SelectionMode = maid mode. FullRowSelect;

// Bind dgv and ContextMenuStrip
DgvList. ContextMenuStrip = cms_list;
List <Song> list = new List <Song> ();
Song s1 = new Song ("001", "Beijing", "D :\\ song \ .mp3 .mp3 ");
Song s2 = new Song ("002", "Beijing", "D :\\ song \ Wu yuyun-life Tree ");
Song s3 = new Song ("003", "Beijing", "D :\\ song \ battle Changsha-Beijing music-pure music version ");

List. Add (s1 );
List. Add (s2 );
List. Add (s3 );

DgvList. DataSource = list;
}

Private void play ToolStripMenuItem_Click (object sender, EventArgs e)
{
FrmPlay frm = FrmPlay. GetInstance ();
Frm. path = dgvList. SelectedRows [0]. Cells [2]. Value. ToString ();
Frm. Show ();
Frm. PlaySong ();
}
}
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.