C# と VB.NET の質問掲示板

ASP.NET、C++/CLI、Java 何でもどうぞ

ログ内検索
  • キーワードを複数指定する場合は 半角スペース で区切ってください。
  • 検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
  • [返信]をクリックすると返信ページへ移動します。
キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
大文字と小文字を区別する

No.89328 の関連記事表示

<< 0 >>
■89328  Re[7]: Form1のテキストボックスの内容をForm2のDGVに
□投稿者/ WebSurfer -(2018/11/20(Tue) 14:36:26)
    No89326 (VB.net Biginner さん) に返信
    > List(Of T)でやろうとしていたのですが、私の理解が及ばず結局
    > idx = DataGridView1.Rows.Count - 1 → idx = DataGridView1.Rows.Count - 2
    > に変更することで思っていた処理になりました。
    
    そういう方法は、すみませんが、自分としては考える気がおきません。
    
    C# でですがサンプルを書いておきますので、これを見てどうするか考えていただくよう
    お願いします。
    
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form5 : Form
        {
            private DataGridView dataGridView1;
            private BindingSource bindingSource1;
    
            public Form5()
            {
                InitializeComponent();
    
                this.dataGridView1 = new DataGridView();
                this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
                this.bindingSource1 = new BindingSource();
                this.dataGridView1.DataSource = this.bindingSource1;
                this.Controls.Add(this.dataGridView1);
    
                List<Item> list = new List<Item>
                {
                    new Item { A = "a1", B = "b1", C = "c1" },
                    new Item { A = "a2", B = "b2", C = "c2" },
                    new Item { A = "a3", B = "b3", C = "c3" }
                };
    
                this.bindingSource1.DataSource = list;
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                Item item = new Item { A = "a0", B = "b0", C = "c0" };
                this.bindingSource1.Insert(0, item);
            }
        }
    
        public class Item
        {
            public string A { get; set; }
            public string B { get; set; }
            public string C { get; set; }
        }
    }
記事No.89287 のレス /過去ログ154より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/

- Child Tree -