关于构造函数的另一个问题 [英] Another question about constructors

查看:74
本文介绍了关于构造函数的另一个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我发布了一个问题,如何从主视图中将表格记录到另一个窗口以获取详细信息视图。 CodeProject的成员对此非常有帮助。我试图再次这样做,但这次没有使用GUID作为我的密钥。我现在正在使用int。我认为我所要做的就是将构造函数中GUID的数据类型更改为int,这样就完成了。我的项目没有收到任何错误,但当我双击表格的一行时,我得到了我的异常消息,我没有选择任何记录。



这是我的MainWindow的代码。

Recently I posted a question how to get a record from a table from my main view in to another window for a "detail" view. The members of CodeProject were extremely helpful with this. I have attempted to do this again but without using a GUID this time as my key. I'm now using an int. I would've thought all I had to do was change the datatype of GUID in my constructor to int and that would be finished. My project is not receiving any errors but when I double click on a row of the table I get my exception message that I have no records selected.

Here is the code from my MainWindow.

private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                System.Data.DataRowView selectedRowView;
                Logscan_RequestDataSet.LOGSCAN_REQUESTRow selectedRow;

                selectedRowView = (System.Data.DataRowView)this.lOGSCAN_REQUESTBindingSource.Current;

                selectedRow = (Logscan_RequestDataSet.LOGSCAN_REQUESTRow)selectedRowView.Row;

                EditRecord editRecordForm = new EditRecord(REQUEST_ID);
                editRecordForm.EditRecord_Selected(selectedRow.REQUEST_ID);
                editRecordForm.Show();
            }
            catch
            {

                MessageBox.Show("You have no record selected.");
            }

        }


       // public Guid GUID { get; set; }


        public int REQUEST_ID { get; set; }









这是我的EditRecord窗口中的代码。







Here is the code from my EditRecord window.

public partial class EditRecord : Form
    {
        public int REQUEST_ID { get; set; }

        public EditRecord(int REQUEST_ID)
        {
            InitializeComponent();
  //         this.REQUEST_ID = REQUEST_ID;
            //this.LOGSCAN_RESQUESTTableAdapter.FillByGuid(this.cj96DataSet.cj96TBRisc, REQUEST_ID);
            this.lOGSCAN_REQUESTTableAdapter.FillByGUID(this.logscan_RequestDataSet.LOGSCAN_REQUEST, REQUEST_ID);
        }

        internal void EditRecord_Selected(int REQUEST_ID)
        {
            this.lOGSCAN_REQUESTTableAdapter.FillByGUID(this.logscan_RequestDataSet.LOGSCAN_REQUEST, REQUEST_ID);
        }

推荐答案

这篇关于关于构造函数的另一个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆