C#这种字符串在delphi中有吗?

孙月魂 2011-05-23 03:43:55

private string classteacher
{
get
{
return this.tbTeacher.Text.Trim();
}
set
{
this.tbTeacher.Text = value;
}

}
private string classseq
{
get
{
return this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["fdClassSeqDataGridViewTextBoxColumn"].Value.ToString();
}
set
{
this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["fdClassSeqDataGridViewTextBoxColumn"].Value = value;
}

}
...全文
107 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
caigeno1 2011-05-27
  • 打赏
  • 举报
回复
好东西!
lhs203203 2011-05-27
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 speak13579 的回复:]
wzwcn谢谢!我用了你的代码,但是为什么我删除数据的时候却提示"list index out of bounds (0)"了?
这是我的代码:

Delphi(Pascal) code

function GetName:String;
procedure SetName(value:String);
private



{ Private d……
[/Quote]

procedure tform1.SetName(value:String);
begin
DBGrid1.DataSource.DataSet.Fields[0].Asstring:= Value;
//相当C#的Set...
end;

wzwcn 2011-05-24
  • 打赏
  • 举报
回复
delphi中和get/set对应的是read/write,比如:

TmyObj=Class(TObject)
private
function GetName:String;
procedure SetName(const value:String);
public
property Name:String Read GetName Write SetName;
end;

implementation

function TmyObj.GetName:String;
begin
//相当C#的Get...
end;

procedure TmyObj .SetName(const value:String);
begin
//相当C#的Set...
end;

孙月魂 2011-05-24
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 sz_haitao 的回复:]
dataset.fieldbyname('xxxx').asstring
[/Quote]
这个我知道,我就是想知道这种字符串在delphi中有没有!就是delphi有没有get\set~~
孙月魂 2011-05-24
  • 打赏
  • 举报
回复
wzwcn谢谢!我用了你的代码,但是为什么我删除数据的时候却提示"list index out of bounds (0)"了?
这是我的代码:

function GetName:String;
procedure SetName(value:String);
private



{ Private declarations }
public

property classseq:String Read GetName Write SetName;



function tform1.GetName:String;
begin
result:=DBGrid1.DataSource.DataSet.Fields[0].Asstring;
//相当C#的Get...
end;

procedure tform1.SetName(value:String);
begin
value:=DBGrid1.DataSource.DataSet.Fields[0].Asstring;
//相当C#的Set...
end;

haitao 2011-05-23
  • 打赏
  • 举报
回复
dataset.fieldbyname('xxxx').asstring
tgbd 2011-05-23
  • 打赏
  • 举报
回复
就是读取和设置文本框、表格单元格的值。
孙月魂 2011-05-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 xfxlylove 的回复:]
有的。你上面的代码用Delphi一样可以实现
[/Quote]
我试了~不行啊!
xfxlylove 2011-05-23
  • 打赏
  • 举报
回复
有的。你上面的代码用Delphi一样可以实现

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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