-
December 11th, 2012, 03:54 PM
#1
[RESOLVED] VB.NET--DataGridView Columns
Hello all,
I'm working on a project with a DataGridView that is filled using a SQL connection. Is there a way to modify (code-behind) the number/names of columns in the DataGridView based upon the fields retrieved by the SQL string?
*Databinding is not an option because I have multiple functions for the DataGridView depending upon a radio button option and each function retrieves different SQL data.
Thank you for your time!
-
December 11th, 2012, 04:24 PM
#2
Re: VB.NET--DataGridView Columns
You can Add columns to the DGV programatically. That way you can dictate the HeaderText, DefaultCellStyle, etc. The important thing, when you are adding a column, is to set the DataPropertyName. This needs to correspond to your data source. If you retreive a column of data and there is no column in the DGV with that specific DataPropertyName the DGV will create a column, and it won't look nice.
-
December 11th, 2012, 04:39 PM
#3
Re: VB.NET--DataGridView Columns
Thank you Mur16. Apparently I've been an air-head all day. I had pre-defined columns setup in design-view. Problem solved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|