本文介绍了如何从C#中的propertygrid控件中检索项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码绑定propertygrid.

Binding propertygrid with following code.

private void dgvDistribution_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
    Distribution di = new Distribution();

    di.VoiceNo = dgvDistribution[1, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.Account_Name = dgvDistribution[2, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.DictatorName = dgvDistribution[6, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.Lastname = dgvDistribution[14, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.Firstname = dgvDistribution[15, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.Middlename = dgvDistribution[16, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.PatientID = dgvDistribution[22, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.MRNO = dgvDistribution[23, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.dateofadmission = dgvDistribution[33, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.Dateofservice = dgvDistribution[26, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.RPhysician = dgvDistribution[24, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.dateofbirth = dgvDistribution[25, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.dictateddatesdifferent = dgvDistribution[34, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.Remarks = dgvDistribution[21, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.ccphy = dgvDistribution[27, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.ccphyinvalid = dgvDistribution[28, dgvDistribution.CurrentRow.Index].Value.ToString();
    di.worktype = dgvDistribution[8, dgvDistribution.CurrentRow.Index].Value.ToString();

    propertyGrid1.SelectedObject = di;
}

推荐答案

Distribution d = PropertyGrid1.SelectedObject as Distribution;
if (d != null)
   {
   Console.WriteLine(d.VoiceNo);
   }


这篇关于如何从C#中的propertygrid控件中检索项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 01:35