1

私は次の小さなフォームを持っています:

ここに画像の説明を入力してください

コントロールをデータベーステーブルにリンクするために、これまでに次のものを入手しました。

テキストボックスをナビゲーターにリンクするのと同じ方法で、datagridviewをナビゲーターにリンクしようとしました-これらのコントロールを結合するための正しい構文は何ですか?

    public SqlCeConnection conn = new SqlCeConnection(ConfigurationManager.ConnectionStrings["WindFormAppRevisionHelper.Properties.Settings.DefinitionsDBConnectionString"].ConnectionString);
    BindingSource rawtableBindingSource = new BindingSource();


    public uxFormDatabase()
    {
        InitializeComponent();
        fillTheDGVusingAdapter();
    }

    public void fillTheDGVusingAdapter()
    {

        SqlCeDataAdapter da = new SqlCeDataAdapter(new SqlCeCommand("Select * From tb_Definitions", conn));
        DataSet ds = new DataSet("DGVdata");
        ds.Tables.Add("rawTable");
        da.Fill(ds.Tables["rawTable"]);

        uxDGVtable.DataSource = ds.Tables["rawTable"];

        rawtableBindingSource.DataSource = ds.Tables["rawTable"];
        uxrawdataBindingNavigator.BindingSource = this.rawtableBindingSource;

         //PROBLEM WITH THE FOLLOWING LINE
        uxDGVtable.DataSource = DataBindings.Add(new Binding("Text", uxrawdataBindingNavigator, "Item_Id", true));

    }
4

1 に答える 1

2

3行前に、uxDGVtableコントロールのデータソースをすでに設定しているため、何をしているのかが少しわかりません。

ナビゲーターが使用しているのと同じBindingSourceを使用してみてください。

// uxDGVtable.DataSource = ds.Tables["rawTable"];
uxDGVtable.DataSource = this.rawtableBindingSource;
于 2012-07-15T12:50:31.310 に答える