KoolKabin
KoolKabin

Reputation: 17653

auto scroll to fixed column datagridview vb.net

I have a datagrid control in my winform application. It has nearly 30 columns. First 2 column are frozen and others can be views using scrollbars.

Its working fine.

I would like to add some functionality on it by allowing user to select a column from column list above and making the datagrid scroll to that column automatically.

So i would like to ask how could i make my datagrid to scroll to specified column automatically.

Upvotes: 1

Views: 8921

Answers (3)

Kristian
Kristian

Reputation: 416

Expanding on the previous answers - If you name your columns then you can do this:

dgvContacts.FirstDisplayedScrollingColumnIndex = colSurname.Index

Upvotes: 0

user2275860
user2275860

Reputation: 57

just put like this:

DataGridView.FirstDisplayedScrollingColumnIndex = DataGridView.Columns.count -1;

Upvotes: 0

KoolKabin
KoolKabin

Reputation: 17653

Got nice answer on:

http://msdn.microsoft.com/en-us/magazine/cc163669.aspx

ie. can be done using "DataGridView.FirstDisplayedScrollingColumnIndex = x"

thnx anyways.

Upvotes: 2

Related Questions