C# 缩短将datagridvie中的值获取到文本框的代码?

C# 缩短将datagridvie中的值获取到文本框的代码?,c#,winforms,C#,Winforms,嗨,伙计们,我想问我如何才能使下面的代码尽可能简短 //oForm.txtboxUsername.Text = lstUsers.CurrentRow.Cells[1].Value.ToString(); //oForm.txtboxPassword.Text = lstUsers.CurrentRow.Cells[3].Value.ToString(); //oForm.cmbAccessLevel.Text = lstUsers

嗨,伙计们,我想问我如何才能使下面的代码尽可能简短

//oForm.txtboxUsername.Text = lstUsers.CurrentRow.Cells[1].Value.ToString();
                //oForm.txtboxPassword.Text = lstUsers.CurrentRow.Cells[3].Value.ToString();
                //oForm.cmbAccessLevel.Text = lstUsers.CurrentRow.Cells[2].Value.ToString();
                //oForm.txtboxFirstname.Text = lstUsers.CurrentRow.Cells[4].Value.ToString();
                //oForm.txtboxMiddlename.Text = lstUsers.CurrentRow.Cells[5].Value.ToString();
                //oForm.txtboxLastname.Text = lstUsers.CurrentRow.Cells[6].Value.ToString();
我尝试了我的旧代码,但我不知道为什么它不起作用

oForm.getalluser = (GetAllUsers)lstUsers.CurrentRow.DataBoundItem;

有什么建议吗?

您应该在窗口窗体应用程序中使用dataset,它会自动将相应的网格字段绑定到我们的控件(工具)。

没有发生任何事情,但我知道我在earl college中使用了它,我正在单击的行中获取当前数据。lstUsers.CurrentRow.DataBoundItem.GetType()的值是多少?