Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataBind with Customization in Datagridview
 

DataBind with Customization in Datagridview

Hi ,

I want to bound datagridview with data with a custmized way

1.I want to change the display order of columns

e.g Sp returned column no 5 i want to display it at the 1 column

Col5.displayIndex=1

This is Not working and does not display the data in grid

The dataset showing me the the rows & columns count in the Qucik watch

But Grid is not showing the data ( May be due to mismatch in columns)

2. I want to display only few selective columns

Not all the columns returned by Sp

How to achieve this

So How we can bind datagridview while format is done by coding

is this is not compatible

as when i not customize the datagridview by coding then it shows the data

Any Help would be very greatful to me.

Thanks in advance

Hr_Ind  Monday, February 06, 2006 5:11 AM

Check out your other post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=237868&SiteID=1

Specifically you need to set the DataPropertyName property for each cololumn you add to make it databound.

-mark

DataGridView Program Manager

Microsoft

This post is provided "as-is"

Mark Rideout  Tuesday, February 07, 2006 6:32 PM
It sounds like you are using the DataGridView with AutoGenerateColumns turned on. Try turning it off and adding columns to the DataGridView yourself, either in the designer or in your own custom code. That should take care of both of your issues.
CommonGenius.com  Monday, February 06, 2006 3:07 PM

yes i m doing the same

AutoGenerateColumnns=false

Then by code i set the columns

then bind the the grid but data is not Comes under that datagridview

Wheareas if i m not setting the display index of the columns then grid shows the data bounded

so why it is not supporting the display index property

Dim col1 As New DataGridViewTextBoxColumn

Dim col2 As New DataGridViewImageColumn

Dim col3 As New DataGridViewTextBoxColumn

Dim col4 As New DataGridViewTextBoxColumn

col1.DisplayIndex = 1

col2.DisplayIndex = 0

col3.DisplayIndex = 2

col4.DisplayIndex = 3

DG.Columns.Add(col1)

DG.Columns.Add(col2)

DG.Columns.Add(col3)

DG.Columns.Add(col4)

Me.DG.DataSource = ds.Tables(0)

this is not working

plz help to solve this

thanks a lot

 

 

Hr_Ind  Tuesday, February 07, 2006 4:48 AM

Check out your other post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=237868&SiteID=1

Specifically you need to set the DataPropertyName property for each cololumn you add to make it databound.

-mark

DataGridView Program Manager

Microsoft

This post is provided "as-is"

Mark Rideout  Tuesday, February 07, 2006 6:32 PM

You can use google to search for other answers

Custom Search

More Threads

• DatagridvewComboBox - databound lists per row
• Auto Sizing DataGridView to Fit XML Table
• How to Access SQLServer Express Database using ADODB?
• customize the background colour in cf.net for datagrid?
• Bindingsource Filter using LIKE on an integer
• Two Connected DataGrids
• Datagridview: SHIFT+SPACE problem
• DataGridView - skip columns with the tab key or arrow keys
• databind a datagrid to an XmlDataSource?
• Formatting a dateTime column