程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> c#完成KTV點歌體系

c#完成KTV點歌體系

編輯:C#入門知識

c#完成KTV點歌體系。本站提示廣大學習愛好者:(c#完成KTV點歌體系)文章只能為提供參考,不一定能成為您想要的結果。以下是c#完成KTV點歌體系正文


上面經由過程圖文並茂的方法給年夜家分享C#完成KTV點歌體系。

public enum SongPlayState
 {
  //未播放,播放,重播,切歌
  unplayed, played, again, cut
 }
 public class Song
 {
  public string SongName { get; set; }//歌曲稱號
  public string SongURL { get; set; }//歌曲途徑
  public SongPlayState playState = SongPlayState.unplayed;//默許未播放
  internal SongPlayState PlayState { get; set; }
  //狀況為已播
  public void SetSongPlayed()
  {
  this.PlayState = SongPlayState.played;
  }
  //重唱
  public void SetPlayAgain()
  {
  this.playState = SongPlayState.again;
  }
  //切歌
  public void SetSongCut()
  {
  this.playState = SongPlayState.cut;
  }

PlayList類中完成切歌 重唱 下一首 等.....

 public class PlayList
 {
  //界說一個長度為、 的歌曲數組,默許存儲 首歌曲
  public static Song[] SongList = new Song[ ];
  public static int SongIndex = ;//以後播放的歌曲在數組中的索引
  //點播一首歌曲,實際上是將歌曲對象添加到歌曲數組中
  public static bool AddSong(Song song)
  {
  bool success = false;//記載添加歌曲能否勝利
  for (int i = ; i < SongList.Length; i++)
  {
   //找到數組中第一個為null的地位
   if (SongList[i] == null)
   {
   SongList[i] = song;
   success = true;
   break;
   }
  }
  return success;
  }
  //獲得以後播放的歌曲::既然是獲得以後播放的歌曲,前往值確定是Song類型
  public static Song GetPlaySong()
  {
  if (SongList[SongIndex] != null)
  {
   return SongList[SongIndex];
  }
  else
  {
   return null;
  }
  }
  /// <summary>
  /// 播放下一首
  /// </summary>
  public static void MoveOn()
  {
  if (SongList[SongIndex] != null && SongList[SongIndex].PlayState == SongPlayState.again)
  {
   SongList[SongIndex].SetSongPlayed();
  }
  else
  {
   SongIndex++;
  }
  }
  /// <summary>
  /// 以後播放的歌曲稱號
  /// </summary>
  /// <returns>歌曲稱號</returns>
  public static string PlayingSongName()
  {
  string songName = ""; // 歌曲稱號
  if (SongList[SongIndex] != null)
  {
   songName = SongList[SongIndex].SongName;
  }
   return songName;
  }
  /// <summary>
  /// 下一重要播放的歌曲稱號
  /// </summary>
  /// <returns>歌曲稱號</returns>
  public static string NextSongName()
  {
  string songName = ""; // 歌曲稱號
  if (SongList[SongIndex + ] != null)
  {
   songName = SongList[SongIndex + ].SongName;
  }
   return songName;
  }
  //重放以後歌曲
  public static void PlayAgain()
  {
  if (SongList[SongIndex] != null)
  {
   SongList[SongIndex].SetPlayAgain();
  }
  }
  //切歌
  public static void CutSong(int index)
  {
  int i;//輪回變量,代表切歌的地位
  if (index == - )//輪回變量,代表切割的地位
  {
   i = SongIndex;
  }
  else
  {
   i = index;//從切歌的地位開端,將歌曲逐一向前移一個地位
  }
  SongList[i].SetSongCut();
  while (SongList[i] != null)
  {
   SongList[i] = SongList[i + ];
   i++; 
   //假如到達數組最初一個元素,就將最初一個元素指向空
   if (i == SongList.Length)
   {
   SongList[i] = null;
   }
  }
  }
 }

完成歌手點歌

 public FrmMain frmMain;
  string connectionStr = "server=.;database=MyKTV;uid=sa";
  DBHelp db = new DBHelp();
  private SqlConnection con;
  //起首要查出數據庫中的圖片途徑和歌曲途徑
  private void FrmCountry_Load(object sender, EventArgs e)
  {
   con = new SqlConnection(connectionStr);
  con.Open();
  string sql = "select resource_path from resource_path where resource_id= ";
   string sqlsongpath = "select resource_path from resource_path where resource_id= ";
  SqlCommand cmd = new SqlCommand(sql,con);
   SqlCommand cmd = new SqlCommand(sqlsongpath, con);
  KtvUnit.ImagePath = cmd.ExecuteScalar().ToString();
  KtvUnit.SongPath = cmd .ExecuteScalar().ToString();
  con.Close();
  }
  //點擊歌手男女或組應時
  private void LvOne_Click(object sender, EventArgs e)
  {
   LoadSingerArea();
  }
  public string singer_type { get; set; }
  private void LoadSingerArea()
  {
  if (this.LvOne.SelectedItems[ ] != null)
  {
   LvOne.Visible = false;
   LvTwo.Location = LvOne.Location;
   LvTwo.Dock = DockStyle.Fill;
   LvTwo.Visible = true;
   this.singer_type=Convert.ToString(LvOne.SelectedItems[ ].Text);
  }
   con = new SqlConnection(connectionStr);
  string sql = "select singertype_id,singertype_name from singer_type";
  SqlCommand cmd = new SqlCommand(sql, con);
  SqlDataReader dr;
  try
  {
   con.Open();
   LvTwo.Items.Clear();
   dr = cmd.ExecuteReader();  
   if (dr.HasRows)
   {
   int index = ;
   while (dr.Read())
   {
    ListViewItem lvItem = new ListViewItem();
    int typeid = Convert.ToInt (dr["singertype_id"]);
    string typename = Convert.ToString(dr["singertype_name"]);
    lvItem.Text = typename;
    lvItem.Tag = typeid;
    lvItem.ImageIndex = index;
    LvTwo.Items.Add(lvItem);
    index++;
   }
   }
   dr.Close();
  }
  catch (Exception ex)
  {
   MessageBox.Show("體系湧現異常" + ex.Message);
  }
  finally 
  {
   con.Close();
  }
  }
  public string singertype_id { get; set; }
  /// <summary>
  /// 點擊地域類型時
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  private void LvTwo_Click(object sender, EventArgs e)
  {
  if (this.LvTwo.SelectedItems[ ] != null)
  {
   LvTwo.Visible = false;
   Lvthree.Location = LvTwo.Location;
   Lvthree.Dock = DockStyle.Fill;
   Lvthree.Visible = true;
   this.singertype_id = Convert.ToString(LvTwo.SelectedItems[ ].Tag);
  }
  string result = singer_type;
  if (result != "組合")
  {
   result = singer_type == "女歌手" ? "女" : "男";
  }
  con = new SqlConnection(connectionStr);
  string sql =string.Format( "select singer_id,singer_name,singer_photo_url from singer_info where singertype_id={ } and singer_Sex='{ }'",singertype_id,result);
  SqlCommand cmd = new SqlCommand(sql, con);
  SqlDataReader dr;
  try
  {
   con.Open();
   int index = ;
   Lvthree.Items.Clear();
   imageList .Images.Clear();
   dr = cmd.ExecuteReader();
   if (dr.HasRows)
   { 
   while (dr.Read())
   {   
    string photoURL =KtvUnit.ImagePath + Convert.ToString(dr["singer_photo_url"]);
    //先給ImageList填充圖片
    imageList .Images.Add(Image.FromFile(photoURL));
    ListViewItem lvItem = new ListViewItem();
    lvItem.Text = Convert.ToString(dr["singer_name"]);
    lvItem.Tag = Convert.ToString(dr["singer_id"]);
    lvItem.ImageIndex = index;
    Lvthree.Items.Add(lvItem);
    index++;
   }
   }
   dr.Close();
  }
  catch (Exception ex)
  {
   MessageBox.Show("體系湧現異常" + ex.Message);
  }
  finally
  {
   con.Close();
  }
  }
  public void SongList()
  {
  //讀取數據庫,讀出該歌手的一切歌曲
   StringBuilder sb = new StringBuilder();
  //拼接SQL語句
  sb.AppendFormat("select song_id,song_name,song_url,singer_name from song_info,singer_info where singer_name='{ }' and song_info.singer_id={ }", Lvthree.SelectedItems[ ].Text, Convert.ToInt (Lvthree.SelectedItems[ ].Tag));
  FrmSongList songList = new FrmSongList();
   songList.Sql = sb.ToString();
  songList.Previous = KtvClient.PrevioisForm.Singer;//指定前往的窗體是按歌手點歌
  songList.ShowDialog();
  this.Close();
  }
  private void Lvthree_Click(object sender, EventArgs e)
  {
  SongList();
  }
  private void tsSingerMain_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Show();
  this.Hide();
  }
  private void tsSingerBack_Click(object sender, EventArgs e)
  {
  if (this.LvOne.Visible==true)
  {
   FrmMain man = new FrmMain();
   man.Show();
   this.Hide();
  }
  else if (this.LvTwo.Visible==true)
  {
   this.LvTwo.Visible = false;
   this.LvOne.Visible = true;
  }
  else if (this.Lvthree.Visible==true)
  {
   this.Lvthree.Visible = false;
   this.LvTwo.Visible = true;
  }
  }
  private void tsSingerCut_Click(object sender, EventArgs e)
  {
  PlayList.CutSong(- );
  }
  private void tsSingerAgain_Click(object sender, EventArgs e)
  {
  PlayList.PlayAgain();
  }
  private void tsSingerYidian_Click(object sender, EventArgs e)
  {
  FrmPlayList frm = new FrmPlayList();
  frm.Show();
  }

拼音點歌

 public FrmMain frmMain;
  [DllImportAttribute("user .dll")]
  private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
  DBHelp db = new DBHelp();
  string connectionStr = "server=.;database=MyKTV;uid=sa";
  private void FrmPinYin_Load(object sender, EventArgs e)
  {
  AnimateWindow(this.Handle, , FrmMain.AW_SLIDE + FrmMain.AW_VER_POSITIVE);
  SqlConnection con = new SqlConnection(connectionStr);
  con.Open();
  db.connection(); 
  string sqlsongpath = "select resource_path from resource_path where resource_id= ";
  SqlCommand cmd = new SqlCommand(sqlsongpath, con);
  KtvUnit.SongPath = cmd.ExecuteScalar().ToString();
  }
  private void btnSearch_Click(object sender, EventArgs e)
  {
  string PinYin = this.txtPinYin.Text;
  //斷定能否是中文 照樣拼音
  if (!Regex.IsMatch(this.txtPinYin.Text, @"^[\u e -\u fa ]+$"))
  {
   StringBuilder PY = new StringBuilder(PinYin);
   for (int i = ; i <= PY.Length; i++)
   {
   PY.Insert(i, "%");
   i++;
   }
   string sql = string.Format("SELECT song_name,singer_name FROM dbo.singer_info, dbo.song_info WHERE dbo.singer_info.singer_id=dbo.song_info.singer_id AND song_ab LIKE '{ }'", PY);
   this.dgvPinYinInfo.DataSource = db.dataTable(sql,"PY");
  }
  else
  {
   StringBuilder ZW = new StringBuilder(PinYin);
   for (int i = ; i < ZW.Length; i++)
   {
   ZW.Insert(i,"%");
   i++;
   }
   string sql = string.Format("SELECT song_name,singer_name FROM dbo.singer_info, dbo.song_info WHERE dbo.singer_info.singer_id=dbo.song_info.singer_id AND song_name LIKE '{ }'", ZW);
   this.dgvPinYinInfo.DataSource = db.dataTable(sql, "PY");
  }
  }
  private void dgvPinYinInfo_DoubleClick(object sender, EventArgs e)
  {
  string songname = this.dgvPinYinInfo.SelectedRows[ ].Cells["song_name"].Value.ToString();
  DBHelp db = new DBHelp();
  db.connection();
  string sql = string.Format("SELECT song_name,singer_name,song_url,song_photo_url FROM dbo.song_info,dbo.singer_info where dbo.singer_info.singer_id=dbo.song_info.singer_id and song_name='{ }'",songname);
   SqlDataReader reader = db.ExecuteReaders(sql.ToString());
   Song song;
  if (reader.Read())
  {
   song = new Song();
   song.SongName = reader["song_name"].ToString();
   song.SongURL = KtvUnit.SongPath+reader["song_url"].ToString();
   PlayList.AddSong(song);  
  }
  reader.Close();
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "a";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "b";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "c";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "d";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "e";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "f";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "g";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "h";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "i";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "j";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "k";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "l";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "m";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "n";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "o";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "p";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "q";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "r";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "s";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "t";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "u";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "v";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "w";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "x";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "y";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "z";
  }
  private void FrmPinYin_FormClosing(object sender, FormClosingEventArgs e)
  {
  AnimateWindow(this.Handle, , FrmMain.AW_SLIDE + FrmMain.AW_VER_POSITIVE);
  }
  public void Binder() 
  {
  string PinYin = this.textBox .Text;
  StringBuilder PY = new StringBuilder(PinYin);
   for (int i = ; i <= PY.Length; i++)
  {
   PY.Insert(i, "%");
   i++;
  }
  string sql = string.Format("SELECT song_name,singer_name FROM dbo.singer_info, dbo.song_info WHERE dbo.singer_info.singer_id=dbo.song_info.singer_id AND song_ab LIKE '{ }'", PY);
  DataSet ds = db.dataSet(sql, "PY");
  if (ds.Tables["PY"]!=null)
  {
   ds.Tables["PY"].Clear();
  }
  this.dgvPinYinInfo.DataSource = db.dataTable(sql, "PY");
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  string text = textBox .Text;
  int index = text.Length - ;
  if (index >= )
  {
   textBox .Text = text.Remove(index);
  }
  }
  private void textBox _TextChanged(object sender, EventArgs e)
  {
  if (textBox .Text!=string.Empty)
  {
   Binder();
   this.dgvPinYinInfo.AutoGenerateColumns = false;
  }
  else
  {
   this.dgvPinYinInfo.DataSource=null;
  }
  }
  private void tsPYMain_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Show();
  this.Hide();
  }
  private void txPYAgain_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Playsong();
  }
  Song song = new Song();
  private void tsPYCut_Click(object sender, EventArgs e)
  {
  song.playState = SongPlayState.cut;
  }
  private void tsPYYidian_Click(object sender, EventArgs e)
  {
  FrmPlayList list = new FrmPlayList();
  list.Show();
  }
  private void tsPYBack_Click(object sender, EventArgs e)
  {
  Application.Exit();
  } 

類型點歌

 public FrmMain frmMain;
  string connectionStr = "server=.;database=MyKTV;uid=sa";
  DBHelp db = new DBHelp();
  private SqlConnection con;
  private void FrmSongType_Load(object sender, EventArgs e)
  {
  con = new SqlConnection(connectionStr);
  con.Open();
  string sql = "select resource_path from resource_path where resource_id= ";
  string sqlsongpath = "select resource_path from resource_path where resource_id= ";
  SqlCommand cmd = new SqlCommand(sqlsongpath,con);
  KtvUnit.SongPath = cmd .ExecuteScalar().ToString();
  SqlCommand cmd = new SqlCommand(sql, con);
  KtvUnit.ImagePath = cmd.ExecuteScalar().ToString();
  con.Close();
   con = new SqlConnection(connectionStr);
  string sql = string.Format("select songtype_id,songtype_name,songtype_URL from song_type");
  SqlCommand cmd = new SqlCommand(sql , con);
  SqlDataReader dr;
  try
  {
   con.Open();
   int index = ;
   lvSongType.Items.Clear();
   imageList .Images.Clear();
   dr = cmd .ExecuteReader();
   if (dr.HasRows)
   {
   while (dr.Read())
   {
    string photoURL = KtvUnit.ImagePath + Convert.ToString(dr["songtype_URL"]);
    //先給ImageList填充圖片
    imageList .Images.Add(Image.FromFile(photoURL));
    ListViewItem lvItem = new ListViewItem();
    lvItem.Text = Convert.ToString(dr["songtype_name"]);
    lvItem.Tag = Convert.ToString(dr["songtype_id"]);
    lvItem.ImageIndex = index;
    lvSongType.Items.Add(lvItem);
    index++;
   }
   }
   dr.Close();
  }
  catch (Exception ex)
  {
   MessageBox.Show("體系湧現異常" + ex.Message);
  }
  finally
  {
   con.Close();
  }
  }
  private void LoadSongType()
  {
  //讀取數據庫,讀出該歌曲類型的一切歌曲
   StringBuilder sb = new StringBuilder();
  //拼接SQL語句
  sb.AppendFormat("select song_info.song_name,singer_info.singer_name,song_info.song_url from singer_info,song_info where song_info.singer_id=singer_info.singer_id and song_info.songtype_id={ }", Convert.ToInt (lvSongType.SelectedItems[ ].Tag));
  FrmSongList songList = new FrmSongList();
   songList.Sql = sb.ToString();
  songList.Previous = KtvClient.PrevioisForm.SongType;//指定前往的窗體是按歌曲類型點歌
  songList.ShowDialog();
  this.Close();
  }
  private void lvSongType_Click(object sender, EventArgs e)
  {
  LoadSongType();
  }
  private void tsTYSingerMain_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Show();
  this.Hide();
  }
  private void tsTYSingerAgain_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Playsong();
  }
  Song song = new Song();
  private void tsTYSingerCut_Click(object sender, EventArgs e)
  {
  song.playState = SongPlayState.cut;
  }
  private void tsTYSingerYidian_Click(object sender, EventArgs e)
  {
  FrmPlayList list = new FrmPlayList();
  list.Show();
  }
  private void tsTYSingerBack_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Show();
  this.Hide();
  }

金榜排行

public FrmMain frmMain;
  DBHelp db = new DBHelp();
  string connectionStr = "server=.;database=MyKTV;uid=sa";
  private void FrmJB_Load(object sender, EventArgs e)
  {
  SqlConnection con = new SqlConnection(connectionStr);
  con.Open();
  db.connection();
  string sql = "SELECT song_name,song_play_count FROM dbo.song_info ORDER BY song_play_count DESC";
  string sqlsongpath = "select resource_path from resource_path where resource_id= ";
  SqlCommand cmd = new SqlCommand(sqlsongpath, con);
  KtvUnit.SongPath = cmd.ExecuteScalar().ToString();
  DataSet ds = db.dataSet(sql,"Count");
  this.dgvSongList.DataSource = ds.Tables["Count"].DefaultView;
  }
  private void dgvSongList_Click(object sender, EventArgs e)
  {
  DBHelp db = new DBHelp();
  if (dgvSongList.SelectedRows[ ]!=null)
  {
   string songname = this.dgvSongList.SelectedRows[ ].Cells["SongName"].Value.ToString();
   db.connection();
   string sql = string.Format("SELECT song_name,singer_name,song_url,song_photo_url FROM dbo.song_info,dbo.singer_info where dbo.singer_info.singer_id=dbo.song_info.singer_id and song_name='{ }'", songname);
   SqlDataReader reader = db.ExecuteReaders(sql.ToString());
   Song song;
   if (reader.Read())
   {
   song = new Song();
   song.SongName = reader["song_name"].ToString();
   song.SongURL = KtvUnit.SongPath + reader["song_url"].ToString();
   PlayList.AddSong(song);
   }
   reader.Close();
  }
  else
  {
   MessageBox.Show("空");
  }
  }
 

數字點歌

 public FrmMain frmMain;
  string connectionStr = "server=.;database=MyKTV;uid=sa";
  DBHelp db = new DBHelp();
  private SqlConnection con;
  private void FrmNumber_Load(object sender, EventArgs e)
  {
  con = new SqlConnection(connectionStr);
  con.Open();
  string sqlsongpath = "select resource_path from resource_path where resource_id= ";
  SqlCommand cmd = new SqlCommand(sqlsongpath, con);
  KtvUnit.SongPath = cmd.ExecuteScalar().ToString();
  con.Close();
  for (int i = ; i <= ; i++)
  {
   for (int j = ; j <= ; j++)
   {
   Label label = new Label();
   label.ForeColor = Color.Red;
   label.BackColor = Color.Pink;
   label.Font=new System.Drawing.Font("漢文彩雲", );
   label.TextAlign = ContentAlignment.MiddleCenter;
   label.Click += label_Click;
   this.MouseMove += FrmNumber_MouseMove;
   label.MouseHover += label_MouseHover;
   label.Size = new System.Drawing.Size( , );
   label.Text = j.ToString();
   if (i > )
   {
    label.Text = (j + i + ).ToString();
   }
   if (i > )
   {
    label.Text = (j + i + ).ToString();
   }
   if (i > )
   {
    label.Text = (j + i + ).ToString();
   }     
   label.Location = new Point( + * j, + * i);
   this.Controls.Add(label);
   }
  }
  }

已點列表

 private void FrmPlayList_Load(object sender, EventArgs e)
  {
  SongList();
  }
  public void SongList() 
  {
  lvSong.Items.Clear();
  for (int i = ; i < PlayList.SongList.Length; i++)
  {
   if (PlayList.SongList[i]!=null)
   {
   ListViewItem item = new ListViewItem();
   item.Text = PlayList.SongList[i].SongName;
   item.Tag = i;
   string playstate = PlayList.SongList[i].PlayState == SongPlayState.unplayed ? "未播放" : "已播";
   item.SubItems.Add(playstate);
   lvSong.Items.Add(item);
   }
  }
  }
  private void btnClose_Click(object sender, EventArgs e)
  {
  this.Close();
  }

以上就是C#完成KTV點歌體系的全體代碼,願望年夜家愛好。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved