473,404 Members | 2,195 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,404 software developers and data experts.

Custom Windows DataGrid

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
6 4328
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris Mayers | last post by:
I have a Windows Forms DataGrid that has a DataView as a datasource. My problem is that I want the datagrid to exhibit some special sorting properties when the header rows are clicked on. From...
2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
1
by: The_Rave | last post by:
Hi everyone, I'm trying to add my own template columns to the property builder of ..NET. E.g. a checkbox column, or an image column. But I can't find the sources of the wizard, or a way to add...
0
by: metamedia | last post by:
How do I get a datagrid to register a data change from a custom control cell (combobox) I've got a Windows Application with a Windows Form Datagrid that has a custom combobox column. When the user...
1
by: Vagabond Software | last post by:
I am creating a custom datagrid based, in part, from someone else's code. The author declared a derived datagrid class in a windows form, then declared a derived ColumnStyle class, in the same form,...
2
by: DraguVaso | last post by:
Hi, I'm looking for a nice way to format the cell of my datagrid according to some predefined 'rules'. I found a lot on the site of George shepherd, but it wasn't really what I was looking for:...
4
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid...
2
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
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: 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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.