473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DataGridView Problem

Hi all,

I have a Datagridview and I have added columns to it it is bound to a
dataset table that is created in the code. The columns order is set and
at the design view it appears just as I want it (I have textbox 5
columns and 1 button column that i want to appear at the end of the
grid as last) but when I run the application the button column that is
supposed to be last jumps to the second place.

I have even tried to set the column order in code but with no luck.

Can anyone help please?

Feb 10 '06 #1
2 2001
Brano wrote:
Hi all,

I have a Datagridview and I have added columns to it it is bound to a
dataset table that is created in the code. The columns order is set and
at the design view it appears just as I want it (I have textbox 5
columns and 1 button column that i want to appear at the end of the
grid as last) but when I run the application the button column that is
supposed to be last jumps to the second place.

I have even tried to set the column order in code but with no luck.

Can anyone help please?


Did you turn off datagridview.autogeneratecolumns?
Feb 10 '06 #2
Yes I did but no luck...

I have actually sorted it out the thing is i am populating the grid in
code and I had to write a code to bound the items.

But the main trick is to execute it after the grid is bound.

Example:
Dim drExists As System.Data.SqlClient.SqlDataReader
drExists = PopulateDataReader(strSQL, My.Settings.ConnStr)

If drExists.HasRows Then
dgResults.DataSource = PopulateDataSet(strSQL,
My.Settings.ConnStr).Tables(0)
pnlGrid.Visible = True
AdjustColumnOrder()
End If

Private Sub AdjustColumnOrder()

With dgResults
.Columns("DateIn").DisplayIndex = 0
.Columns("CustSurname").DisplayIndex = 1
.Columns("MiddleName").DisplayIndex = 2
.Columns("DOB").DisplayIndex = 3
.Columns("PostCode").DisplayIndex = 4
.Columns("btnSelect").DisplayIndex = 5
End With

End Sub

Feb 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Henok Girma | last post by:
Hello Gurus, I want to save the state of an unbound DataGridView on my Windows Form application to an XML file so i can later load it back.. Basically, on my form I have a DataGridView, it's got...
1
by: Dave A | last post by:
Hi, I am struggling with two way databinding in WinForms and the DataGridView. I am binding to business object classes (rather than datatables). If I have a collection of these business...
1
by: sapkal.manish | last post by:
Question : How can I find actual row position of DataTable in DataGridView when DataTable is sorted / My source code like this Private WithEvent dgvInwDet as new DataGridView Private...
1
by: Rich | last post by:
Hello, I am reading data from a sql server table that is under replication. This table has the replicatin GUID column that is generated with replicatin. I am reading the data from a...
2
by: Rich | last post by:
Hello, Following an example at http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken Tucker) on binding a dataRelation to a Datagridview for sqlClient, I was able to view rows...
2
by: Rick Shaw | last post by:
Hi, I have a problem with the datagridview not refreshed when the application first appear on the screen. The datagridview display data from a table in the dataset. At the same time, I've added...
11
by: Kevin | last post by:
I've been searching forever for examples of saving data changes in a DataGridView. There's all kinds of examples, but none really show how to save changes. Someone please help me. I have a...
3
by: Daniel Manes | last post by:
I need a strategy to debug this situation... I can't put all the code involved, but here are some of the critical lines with comments: ------------------------- Private _parentDataCell As...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
1
by: Jeff | last post by:
Hey ..NET 2.0 I've created a User Control which contain a DataGridView. This User Control is displayed on a TabPage. This TabPage is added to the TabControl during runtime. The problem is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.