关于get/set的问题

pvm6b2 2008-12-18 11:20:43
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace haiyang
{
public partial class mytextbox : UserControl
{
Cls_UserManage um = new Cls_UserManage();
dbopt opt = new dbopt();

private string pos_name="";
public string itempos_name
{
get
{
return pos_pos_name.Text;
}
set
{
pos_name = value;
this.pos_pos_name.Text = pos_name;
}
}
private string shipno="";
public string itemshipno
{
get
{
return pos_shipno.SelectedValue.ToString();
}
set
{
shipno = value;
this.pos_shipno.SelectedText = shipno;

}
}
private string studyshipno="";
public string itemstudyshipno
{
get
{
return pos_studyshipno.SelectedValue.ToString();
}
set
{
studyshipno = value;
this.pos_studyshipno.SelectedText = studyshipno;
}
}
private string haishan;
public string itemhaishan
为什么我调用xxx.itemstudyshipno = "xxxx" 就会出现未将对象引用到实例,如何解决这个问题,想不出来了。
...全文
107 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
claymore1114 2008-12-18
  • 打赏
  • 举报
回复
首先 你要引用命名空间haiyang using haiyang; 再实例化
初始化属性赋值:xxx.itemstudyshipno = "xxxx";
访问属性: string x=xxx.itemstudyshipno;
GTX280 2008-12-18
  • 打赏
  • 举报
回复
楼主设断点调试一下
调用xxx.itemstudyshipno = "xxxx"的时候可能this.pos_studyshipno为空
码农2007 2008-12-18
  • 打赏
  • 举报
回复
xxx x = new xxx();
x..itemstudyshipno = "xxxx";
应该就可以了。。。

必须用实例对像调用
萤火架构 2008-12-18
  • 打赏
  • 举报
回复
xxx 初始化了吗?
pos_studyshipno初始化了吗?

请检查下初始化顺序
navysong 2008-12-18
  • 打赏
  • 举报
回复
o,原来是EVENT机制
看来微软的控件确实用好不易
pvm6b2 2008-12-18
  • 打赏
  • 举报
回复
控件引用肯定没问题,可是上面的combobox上得selectvalue必须选择了才能返回,如果用户不选择,直接get就会出现,未将对象引用到实例

111,130

社区成员

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

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

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