记住从先前表格中选择的内容 [英] remember selection from previous form

查看:116
本文介绍了记住从先前表格中选择的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个添加人表格,其中有一个名为保存和编辑医疗详细信息"的按钮.我想做的是单击此按钮,打开医疗详细信息表单,并且此表单中的datagrid视图已经选择了正确的人员ID.
因此,如果我添加了一个名为paul的新成员,则医疗表格datagrid视图将已经选择了paul进行编辑

Hi everyone, i have an add person form in which have a button called "save and edit medical details". What i would like to do is when this button is clicked, the medical details form is opened up and the datagrid view in this form already has the correct person ID selected.
So if i added a new member called paul, the medical form datagrid view would already have paul selected for editing

thanks for your time!

推荐答案

只需在编辑表单的构造函数中传递新成员的ID,然后使用它在数据网格中选择合适的人.

希望这会有所帮助.

回复您的评论.
假设您的第二个表单称为EditForm,那么您将在此表单中创建一个构造函数,该构造函数接受一个表示所选成员id的int.然后,表单将使用此信息来选择合适的成员,例如(伪代码):-

Just pass the id for the new member in the constructor of the edit form, and use it to select the right person in the datagrid.

Hope this helps.

In reply to your comment.
Say your second form was called EditForm, then you would create a constructor in this form that takes an int representing the selected members id. Then the form would use this information to select the right member, something like this (pseudocode):-

public class EditForm
    {
        public EditForm(int memberID)
        {
            datagrid1.SelectedPerson = from person in datagrid1.datasource where person.id == memberID;
        }
    }



然后,当您按如下所示单击按钮时,您将打开此表单:-



Then you would open this form when the button is clicked like this:-

private void btnSaveAndEdit_Click(object sender, EventArgs e)
       {
           EditForm e = new EditForm(paulsID);
           e.showdialogue();
       }


显然,这不是真正的代码,但是应该让您了解如何实现它.


This is obviously not real code, but should give you the idea of how to go about it.


这篇关于记住从先前表格中选择的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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