473,491 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Scrolling problems in datagrid with invisible columns

Hello,

We're doing our own datagrid based on the System.windows.forms.datagrid
control, and are having some problems with horizontal scrolling.

In general, we construct our datagrid adding a tablestyle and
gridcolumnstyles to that tablestyle. If we have invisible columns, we add
the gridcolumnstyle with Width = 0 (couldn't find any other way to do it,
because there is no Visible property available...).

When we change column with the TAB key, it doesn't work right if the
invisible columns are in the visible area of the grid. Looking at the code
of the EnsureVisible method of the datagrid, it's something like this:
-----------------------------------------------------------
private void EnsureVisible(int row, int col) {
int local0;
if (row < this.firstVisibleRow || row >= this.firstVisibleRow +
this.numTotallyVisibleRows) {
local0 = this.ComputeDeltaRows(row);
this.ScrollDown(local0);
}
if (this.firstVisibleCol != 0 || this.numVisibleCols != 0 ||
this.lastTotallyVisibleCol != -1)
goto i-1;
return;
do {
this.ScrollToColumn(col);
} while (col < this.firstVisibleCol || col == this.firstVisibleCol &&
this.negOffset != 0 || this.lastTotallyVisibleCol == -1 && col >
this.firstVisibleCol || this.lastTotallyVisibleCol > -1 && col >
this.lastTotallyVisibleCol);
}
-----------------------------------------------------------
The problem is that, even if we can't see, for example, the column 0 because
it has its Width=0, the datagrid keeps saying that FirtsVisibleCol=0, so it
doesn't scroll right when it should. I guess the same is happening with the
rest of the private properties (numVisibleCols and lastTotallyVisibleCol)

Anybody has any ideas of how we can solve this problem? Is there a way to
tell the datagrid that Column0 is actually invisible?

Right now, the only way I can think of doing it is controlling columns with
Width=0 and scrolling the grid "by hand"...

Thank You very much,

Igor Mendizabal
Nov 21 '05 #1
3 1485
Igor,

Not using a column in a datagrid with styles means not creating a column for
it, what is your problem with that?

And when you don't use a style than you can hide it.

See this sample on our site, there are more samples about styles on our
site.

http://www.windowsformsdatagridhelp....3-a3539697edbd

(Using columns in a datagrid has always to do with mappings.)

I hope this helps,

Cor

Nov 21 '05 #2
Hello Cor,

I thought about your suggestion, but doesn't work in our case. The problem
is that our grids are mostly configurable by the user (they can
enable/reorder/hide columns), and there is a lot of code written by now that
accesses those columns, even if they are hidden, because it supposes that
they are there, only that we can't see them.

Anyway, I tried not to add the invisible gridcolumnstyles, and even thogh
the scrolling works fine, I broke more things than I fixed with that change,
so I'm gonna try to control if it should scroll in the CurrentCellChanged
event, and use the GridHScrolled method to make it scroll.

Thank you very much anyway,

Igor

"Cor Ligthert [MVP]" <no************@planet.nl> escribió en el mensaje
news:O7**************@TK2MSFTNGP09.phx.gbl...
Igor,

Not using a column in a datagrid with styles means not creating a column for it, what is your problem with that?

And when you don't use a style than you can hide it.

See this sample on our site, there are more samples about styles on our
site.

http://www.windowsformsdatagridhelp....3-a3539697edbd
(Using columns in a datagrid has always to do with mappings.)

I hope this helps,

Cor

Nov 21 '05 #3
Igor,

AFAIK is setting the mapping of a column to nothing enough to do what you
want when you use tablestyles.

Cor
Nov 21 '05 #4

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

Similar topics

3
1863
by: Igor Mendizabal | last post by:
Hello, We're doing our own datagrid based on the System.windows.forms.datagrid control, and are having some problems with horizontal scrolling. In general, we construct our datagrid adding a...
1
1491
by: Steve Leckman | last post by:
I have a datagrid with multiple Columns. I want to control the Horizontal scrolling, so that the left two most columns DO NOT scroll when the scroll bar is used. Only the 3rd+ Columns scroll left...
4
5330
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
0
1365
by: Robert Brinson | last post by:
Hello all! I'm running .NET Framework 1.1 using VS.NET 2003. I've got a mystery with a DataGrid. Below is the definition of the DataGrid from my aspx page: </asp:datagrid><asp:datagrid...
15
3733
by: John Blair | last post by:
Hi, Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist....
2
2646
by: Not Me | last post by:
Hi, In a datagrid's itemcommand method, I can use DataGridCommandEventArgs/item/cells/text to bring up a specific field from a row that was accessed. However, I wish to lookup data from that...
1
1436
by: Willem | last post by:
Hi, I'm using a datagrid on a webform with 4 visible and 1 invisible columns. When clicking a button I want to make the invisible column visible. I use the code DataGrid1.Columns(4).Visible =...
0
1812
by: Daniel Doyle | last post by:
Hello and apologies in advance for the amount of code in this post. I've also sent this message to the Sharepoint group, but thought that ASP.NET developers may also be able to help, even though...
1
2319
by: John Bayly via .NET 247 | last post by:
I'm working on an inherited Datagrid class that includes afunction called onMouseMove to paint the row under the cursor tomake reading easier for users. To paint the row, the function sets the...
3
1694
by: Phillip N Rounds | last post by:
I have a DataGrid in a web form (ASP1.1, C#, VS 2003) that I'm trying to add some functionality to, and I can't figure out how to do int. The existing DataGrid has several databound columns and a...
0
7115
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
6978
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...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
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...
1
4881
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...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.