Hello, thanks for your reply.
"Linda Liu [MSFT]" wrote:
> Hi Roger,
>
> The DataGridView.AutoGenerateColumns property indicates whether columns are
> created automatically when the DataSource or DataMember properties are set.
>
> If the AutoGenerateColumns property is set to false, the columns won't be
> generated automatically while the the DataSoure or DataMember properties
> are set.
>
> If the AutoGenerateColumns property is set to true, when the DataSource or
> DataMember properties are set, DataGridView will automatically generate a
> column for each field in the data source that hasn't been bound to the
> existing columns in the DataGridView .
>
> For example, we have a DataSet containing a DataTable, and the DataTable
> has three fields--ID, Name and Age in it. We have a DataGridView and add a
> DataGridViewTextBoxColumn into it. We set the DataGridViewTextBoxColumn's
> DataPropertyName property to "ID" and then set the DataGridView's
> DataSource property to the DataSet and DataMember property to the DataTable
> name.
>
> Only two columns are generated automatically for the "Name" and "Age"
> fields respectively, because the "ID" field has been bound to the existing
> DataGridViewTextBoxColumn in the DataGridView.
>
> As for your question, I suggest that you add a DataGridViewComboBoxColumn
> in the DataGridView and set the DataPropertyName property of the column to
> the field in the data source you'd like to bind to BEFORE you set the
> DataSource or DataMember properties of the DataGridView.
>
> The following is a sample code snipt.
>
> DataGridViewComboBoxColumn column1 = new
> DataGridViewComboBoxColumn();
> column1.Items.Add("1");
> column1.Items.Add("2"); // you could also set the column's
> DataSource property
> column1.DataPropertyName = "ID";
> this.dataGridView1.Columns.Add(column1);
>
> this.dataGridView1.DataSource = this.dataSet11;
> this.dataGridView1.DataMember = "TableName";
>
> Hope this helps.
> If you have any question, please feel free to let me know.
>
> Sincerely,
> Linda Liu
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
>
http://msdn.microsoft.com/subscriptions/support/default.aspx. > ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>