C#中的问题
大家好,我现在是一名C#的新手,在编写窗体应用程序的时候遇到一个问题,不知道该怎解决,希望大家能够提供帮助!using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace media
{
public partial class Form1 : Form
{
string uu = "0";
public Form1()
{
InitializeComponent();
RegistryKey xx = Registry.LocalMachine;
RegistryKey xx1 = xx.OpenSubKey("SOFTWARE", true);
string ss = "";
foreach (string site in xx1 .GetSubKeyNames ())
if (site == "ww")
{
ss = "AA";
RegistryKey xx2 = xx1.OpenSubKey("ww",true);
foreach (string tt in xx2.GetSubKeyNames())
listBox1.Items.Add(tt);
break;
}
if (ss != "AA")
{
xx1.CreateSubKey("ww");
}
xx.Close();
if (listBox1.Focused == false)
{
delmovie.Enabled = false;
upmovie.Enabled = false;
downmovie.Enabled = false;
}
else
{
delmovie.Enabled = true;
upmovie.Enabled = true;
downmovie.Enabled = true;
}
}
private void addmovie_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Media Files|*.mpg;*.avi;*.wma;*.mov;*.wav;*.mp2;*.mp3|All Files|*.*";
openFileDialog1.ShowDialog();
RegistryKey xx = Registry.LocalMachine;
RegistryKey xx1 = xx.OpenSubKey("SOFTWARE",true );
RegistryKey xx2 = xx1.OpenSubKey("ww",true );
xx2.SetValue(openFileDialog1.FileName, openFileDialog1.FileName, RegistryValueKind.String);
xx.Close();
listBox1.Items.Add(openFileDialog1.FileName);
}
private void delmovie_Click(object sender, EventArgs e)
{
if (axWindowsMediaPlayer1.URL == listBox1.SelectedItem.ToString())
{
axWindowsMediaPlayer1.Ctlcontrols.stop();
axWindowsMediaPlayer1.URL = "";
axWindowsMediaPlayer1.Update();
}
RegistryKey xx = Registry.LocalMachine;
RegistryKey xx1 = xx.OpenSubKey("SOFTWARE",true );
RegistryKey xx2 = xx1.OpenSubKey("ww",true );
xx2.DeleteSubKey(listBox1 .SelectedItem .ToString ());
xx.Close();
uu = "1";
listBox1.Items.Remove(listBox1.SelectedItem);
listBox1.Update();
}
private void upmovie_Click(object sender, EventArgs e)
{
int index = -1;
object lt = new object(listBox1 .SelectedItem.Text,listBox1 .SelectedValue );
listBox1 .Items [listBox1 .SelectedIndex ].Text=listBox1 .Items [listBox1 .SelectedIndex +index ].Text;
listBox1 .Items [listBox1 .SelectedIndex ].Value=listBox1 .Items [listBox1 .SelectedIndex +index ].Value;
listBox1 .Items [listBox1 .SelectedIndex ].Text=lt.Text;
listBox1.Items[listBox1.SelectedIndex].Value = lt.Value;
listBox1.Items[listBox1.SelectedIndex].Value = lt.Value;
}
private void downmovie_Click(object sender, EventArgs e)
{
int index = 1;
object lt = new object(listBox1 .SelectedIndex .Text,listBox1 .SelectedValue );
listBox1 .Items [listBox1 .SelectedIndex ].Text=listBox1 .Items [listBox1 .SelectedIndex +index ].Text;
listBox1 .Items [listBox1 .SelectedIndex ].Value=listBox1 .Items [listBox1 .SelectedIndex +index ].Value;
listBox1.Items[listBox1.SelectedIndex].Text = lt.Text;
listBox1.Items[listBox1.SelectedIndex].Value = lt.Value;
listBox1.Items[listBox1.SelectedIndex].Value = lt.Value;
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
upmovie.Enabled = true;
downmovie.Enabled = true;
delmovie.Enabled = true;
if (uu == "0")
{
axWindowsMediaPlayer1.URL = listBox1.SelectedItem.ToString();
}
else
{
uu = "0";
axWindowsMediaPlayer1.URL = "";
}
axWindowsMediaPlayer1.Ctlcontrols.stop();
}
}
}
在调试以上代码时出现以下错误:错误 1 “object”不包含“Text”的定义,并且找不到可接受类型为“object”的第一个参数的扩展方法“Text”(是否缺少 using 指令或程序集引用?) D:\vs2008\media\media\Form1.cs 83 59 media
错误 9 “object”不包含“Value”的定义,并且找不到可接受类型为“object”的第一个参数的扩展方法“Value”(是否缺少 using 指令或程序集引用?) D:\vs2008\media\media\Form1.cs 87 63 media
请问是不是少了什么命名空间?在编写程序的过程中
object lt = new object(listBox1 .SelectedIndex .后面不能自动出现Text或者Value盼解决!