C#中的问题

lenovo030130 2010-10-10 09:06:59
大家好,我现在是一名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盼解决!
...全文
147 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
nmz2032964 2011-04-21
  • 打赏
  • 举报
回复
什么啊 看不到
HolyPlace 2010-10-10
  • 打赏
  • 举报
回复
listBox1.SelectedIndex 下面是没有text属性的
wuyq11 2010-10-10
  • 打赏
  • 举报
回复
Object 所有类的最终基类
自定义实体类,通过属性取值
YellowManDog 2010-10-10
  • 打赏
  • 举报
回复
object lt = new object(listBox1 .SelectedIndex .Text,listBox1 .SelectedValue );
你的lt是object对象,没有那两个属性,你如果要用lt的值你直接用lt.ToString()就行

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧