本文介绍了如何获取DatagridView的价值并以表格形式传输数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建Windows应用程序,我需要更新供应商的datagridview并将选定的行转移到另一个表单中进行编辑

请帮助我:(我如何使用vb.net编写此代码?使用ado.net?

I''m creating my windows application and I need to update my supplier''s datagridview and transfer the selected rows to another form for editing

help me please :( how will I code this one using vb.net? using ado.net?

推荐答案

MyForm frm = new MyForm();
// It is possible to set MyValue at any point in your code, as long as you have a reference to an instance of MyForm.
frm.MyValue = "some value";
frm.Show();


另一种是将其传递给构造函数.


Another is passing it to the constructor.

public partial class MyForm : Form
{
   private String _myValue;
   public Form1(String myValue)
   {
      InitializeComponent();
      _myValue = myValue;
      // Possibly use myValue here.
   }
   // Do stuff with _myValue here.
}

用法如下:

Usage would look like this:

MyForm frm = new MyForm("some value");
frm.Show();


另一种方法是使用方法...


Another approach could be to use a Method...

public partial class MyForm : Form
{
   private String _myValue;
   public void SetValue(String myValue)
   {
      _myValue = myValue;
     // Possibly do stuff with myValue here.
   }
   // Or use _myValue here.
}

用法:

MyForm frm = new MyForm();
frm.Show();
// Once again, you can use this anywhere in your code, as long as you have a reference to the instance of MyForm.
frm.SetValue("some value");



因此,现在您将数据保存在另一个表单中,只需在此处处理,编辑等,然后在其原始来源的表单中对其进行更新.
您也可以对未绑定的数据执行此操作,除了更新原始网格可能需要一些额外的工作.

该代码在C#中,但是任何转换器 [ ^ ]可以为您将其转换为VB :)

希望对您有所帮助:)



So now you got your data in another Form, all you need to do is handle it there, edit it etc. and update it in the Form it originally came from.
You can also do this with unbound data, except the updating of your original grid might be some extra work.

The code is in C#, but any convertor[^] can convert it to VB for you :)

Hope it helps :)


Dim x as String = Me.DatagridView1.Rows(1).Cells("ColumnName").value


;)


这篇关于如何获取DatagridView的价值并以表格形式传输数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 08:19