By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,922 Members | 2,013 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,922 IT Pros & Developers. It's quick & easy.

Custom Windows DataGrid

P: n/a
I have a custom-built datagrid for windows forms. I overrode the
scrollbars in it because I wanted to draw my own (basically, they're
skinned). As a result, I handle all scroll events and calls. I also
have a row-selector column as the first column, and that needs to stay
visible. Think Excel. However, if a user clicks a cell that is all
the way to the right and goes off the grid a bit, then the entire grid
shifts, including my row-selector column. I can't find any event that
seems to coincide with this. Yes, CurrentCellChanged fires, but by
then it's too late to prevent the grid from scrolling.
So, does anyone know a good way to make a column freeze (this is a
windows forms application), and how can I prevent the grid from auto
scrolling? Thanks

Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Bob,

I don't know if you have planned to use VB2005 soon.

Be aware that the datagridview makes a lot of what you are doing now
completly unneeded.

http://msdn.microsoft.com/library/de...tml/vs05a9.asp

And as I tried it, it is in my opinion even nicer than that.

Cor
Nov 21 '05 #2

P: n/a
Bob,

I don't know if you have planned to use VB2005 soon.

Be aware that the datagridview makes a lot of what you are doing now
completly unneeded.

http://msdn.microsoft.com/library/de...tml/vs05a9.asp

And as I tried it, it is in my opinion even nicer than that.

Cor
Nov 21 '05 #3

P: n/a
Perhaps, but this is for a large-scale commercial application that's
been in development for over 2 years. We're releasing 2.5 soon and
really don't have time/resources to convert to 2005. Believe me, I've
been reading all the great stuff that's in VB2005 and SQL 2005, but
until then, I have to re-create these features in 2003. Thanks
anyway...

Nov 21 '05 #4

P: n/a
Perhaps, but this is for a large-scale commercial application that's
been in development for over 2 years. We're releasing 2.5 soon and
really don't have time/resources to convert to 2005. Believe me, I've
been reading all the great stuff that's in VB2005 and SQL 2005, but
until then, I have to re-create these features in 2003. Thanks
anyway...

Nov 21 '05 #5

P: n/a
DWS
Bob,
I know how cool custom scrolls can be. This is just me I would make all the
columns fit exactly on the visible display area of the data grid by adjusting
the column width. Too many columns then hide the columns that don't fit.
You'll have to use the tablestyles collection
Its dificult to setup but here goes
click properties
set the width to 420
select tablestyles collection and go to the designer ...
add a tablestyle just click the big add button
in the mapping name select your datamember (datamember on grid) name from
the drop down list
go into the grid columns styles collection designer ... (same designer)
in the mapping name select your first column from the drop down list.
set width to 100
do the same for the next three columns
for all the remaining columns set the width to zero.
when you run the datagrid will display the first four columns.
In the cool scroll click to move right. make columns visible by changing
the width to non zero.

datagrid1.TableStyles.Item(0).GridColumnStyles.Ite m(0).Width=0
datagrid1.TableStyles.Item(0).GridColumnStyles.Ite m(4).Width=100

Sorry I don't know how to progamatically create a table styles collection at
run time you'll have to do it manually in the designer.

Good Luck
DWS

"Bob The Builder" wrote:
I have a custom-built datagrid for windows forms. I overrode the
scrollbars in it because I wanted to draw my own (basically, they're
skinned). As a result, I handle all scroll events and calls. I also
have a row-selector column as the first column, and that needs to stay
visible. Think Excel. However, if a user clicks a cell that is all
the way to the right and goes off the grid a bit, then the entire grid
shifts, including my row-selector column. I can't find any event that
seems to coincide with this. Yes, CurrentCellChanged fires, but by
then it's too late to prevent the grid from scrolling.
So, does anyone know a good way to make a column freeze (this is a
windows forms application), and how can I prevent the grid from auto
scrolling? Thanks

Nov 21 '05 #6

P: n/a
That's essentially what I'm doing now, except it's programmatically. I
have a class that inherits from DataGridTextBoxColumn (for custom
coloring and properties). I iterate through the columns in my
DataSource, and call BaseStyle.GridColumnStyles.Add(gridCol), where
gridCol is my DataGridTextBoxColumn.
But, scrolling with the scrollbar really isn't the issue. The problem
is when a user clicks on a cell that hangs off the edge of the grid.
That is, a cell whose .Left property is within the grid, but .Left +
..Width is beyond the width of the grid. And the columns must have
variable width.

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.