MSDN > フォーラム ホーム > Windows Forms Data Controls and Databinding > DataGridView automatically adding columns I don't want !!?!
質問する質問する
 

回答済みDataGridView automatically adding columns I don't want !!?!

  • 2007年5月4日 15:11JBalcerzak ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    Hello -

     

    I'm sure this is something simple, but I've got a databound DataGridView where I have several columns from the data source and some unbound columns like buttons and so forth.  The problem is that every time I go to make simple changes through the column editor, I see that VS 2005 has added ALL the columns from the datasource to the grid - even columns that I already had in there.  While its not a problem to remove the additional columns, I'd sure like to know if there was a way to prevent VS 2005 from doing this seemingly every time.

     

    Thanks,

     

    Jeff Balcerzak

回答

  • 2007年5月4日 18:51timvw ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み
    Well, i just tried it:

    - The columns that where added by the designer disappear
    - The columns that you added manually remain (and if you set their datapropertyname to a property that existed on the datasource this datapropertyname remains too)

すべての返信

  • 2007年5月4日 15:16timvw ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Clear the DataSource property.. And in the constructor of your form set this.dataGridView.AutoGenerateColumns = false;
  • 2007年5月4日 16:09JBalcerzak ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    If I clear my data source, won't I lose the columns I already have defined?  You'd think that auto create columns property would be visible at design time...
  • 2007年5月4日 18:51timvw ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み
    Well, i just tried it:

    - The columns that where added by the designer disappear
    - The columns that you added manually remain (and if you set their datapropertyname to a property that existed on the datasource this datapropertyname remains too)