苏飞论坛

标题: 分布式框架开发winform程序,关联字段 [打印本页]

作者: xtulhh    时间: 2014-12-23 14:28
标题: 分布式框架开发winform程序,关联字段
本帖最后由 xtulhh 于 2014-12-23 15:36 编辑

我是新手,请教一下,我要用分布式框架开发winform程序,关联表的字段或需要转化为中文显示的时候在表格控件中的字段名我应该怎么写.比如:两个表A(Id,Name),B(BId,AId),其中AId关联A表的Id,我在显示B表数据时需要怎么转换B表的AId显示成A表的Name字段数据,也就是说对应的DataPropertyName属性应该是怎么写.

作者: 站长苏飞    时间: 2014-12-23 17:03
http://www.sufeinet.com/thread-10637-1-1.html
作者: xtulhh    时间: 2014-12-24 10:16
站长苏飞 发表于 2014-12-23 17:03
http://www.sufeinet.com/thread-10637-1-1.html

这个查询出来已经了解.可是要在表格中绑定不知道应该怎么写字段名.因为查出来的List数据只是B表的字段,也就是说只有两个字段BId,AId.
作者: 站长苏飞    时间: 2014-12-24 10:18
绑定使用 For循环
作者: xtulhh    时间: 2014-12-25 09:25
站长苏飞 发表于 2014-12-24 10:18
绑定使用 For循环

在web程序中可以这样,在winform程序中不知道应该怎么写

作者: songwenqi    时间: 2014-12-26 08:39
xtulhh 发表于 2014-12-25 09:25
在web程序中可以这样,在winform程序中不知道应该怎么写

可以这样,
<%#(Eval("ExData") as Dictionary<string, object>)["Name"]%>
Name是在分布式关联时自定义的属性,取得时候这样取就可以。
作者: 自强不息    时间: 2014-12-30 11:13
本帖最后由 自强不息 于 2014-12-30 11:21 编辑
xtulhh 发表于 2014-12-25 09:25
在web程序中可以这样,在winform程序中不知道应该怎么写

1: //生成新的行
2:for循环给每行赋值。
[C#] 纯文本查看 复制代码
 #region 委托 dataGridView1  增加一行

        public delegate void SafeAddRowCall();

        public void AddRow()
        {
            this.dataGridView1.Rows.Add();
        }

        public void SafeAddRow()
        {
            if (this.dataGridView1.InvokeRequired)
            {
                SafeAddRowCall sarc = new SafeAddRowCall(AddRow);
                this.dataGridView1.Invoke(sarc);
            }
            else
            {
                this.dataGridView1.Rows.Add();
            }

        }
        #endregion

        /// 行索引
        /// 标题名称
        /// 值
        public void SafeUpdateValue(int RowIndex, string ColumnName, string value)
        {
            if (this.dataGridView1.InvokeRequired)
            {
                SafeUpdateValueCall suvc = new SafeUpdateValueCall(UpdateValue);
                this.dataGridView1.Invoke(suvc, RowIndex, ColumnName, value);
            }
            else
            {
                this.dataGridView1.Rows[RowIndex].Cells[ColumnName].Value = value;
            }

        }
        #region 使用委托 更新 dataGridView1 中某一行某一列的值

        public delegate void SafeUpdateValueCall(int RowIndex, string ColumnName, string value);

        public void UpdateValue(int RowIndex, string ColumnName, string value)
        {
            this.dataGridView1.Rows[RowIndex].Cells[ColumnName].Value = value;
        }
        #endregion


作者: xtulhh    时间: 2014-12-30 16:02
自强不息 发表于 2014-12-30 11:13
1: //生成新的行
2:for循环给每行赋值。
[mw_shl_code=csharp,true] #region 委托 dataGridView1  增 ...

是的,估计只能用生成新的行,谢谢





欢迎光临 苏飞论坛 (http://www.sufeinet.com/) Powered by Discuz! X3.4