473,779 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
+ 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
gridcolumnstyle s 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(i nt row, int col) {
int local0;
if (row < this.firstVisib leRow || row >= this.firstVisib leRow +
this.numTotally VisibleRows) {
local0 = this.ComputeDel taRows(row);
this.ScrollDown (local0);
}
if (this.firstVisi bleCol != 0 || this.numVisible Cols != 0 ||
this.lastTotall yVisibleCol != -1)
goto i-1;
return;
do {
this.ScrollToCo lumn(col);
} while (col < this.firstVisib leCol || col == this.firstVisib leCol &&
this.negOffset != 0 || this.lastTotall yVisibleCol == -1 && col >
this.firstVisib leCol || this.lastTotall yVisibleCol > -1 && col >
this.lastTotall yVisibleCol);
}
-----------------------------------------------------------
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 lastTotallyVisi bleCol)

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
Jul 22 '05 #1
3 1882
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

Jul 22 '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 gridcolumnstyle s, 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 CurrentCellChan ged
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******** ******@TK2MSFTN GP09.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

Jul 22 '05 #3
Igor,

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

Cor
Jul 22 '05 #4

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

Similar topics

1
1512
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 or right when the Horizontal Scroll bar is used. Anyone know how to do this?? Thanks!! Steve
4
5357
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. Currently everything is working. I can find the updated rows/columns by parsing the posted data collection against the DataGrid DataSource. However, when there is a large amount of DataGridItems (rows) the update processing can take a while. ...
0
1388
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 id="dgDetails" Runat="server" Width="100%" Visible="False" AllowSorting="True" CellPadding="1" CellSpacing="0" AutoGenerateColumns="False" OnSortCommand="SortDetails"> <ItemStyle Font-Size="XX-Small" Font-Names="Tahoma"></ItemStyle> <HeaderStyle...
15
3765
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. How do i hide a column? Thanks. MyConnection = New SqlConnection("server=(local);database=pubs;Trusted_Connection=yes") MyCommand = New SqlDataAdapter("select * from Authors",
1
1451
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 = True All fine, but the problem is that the columnwidth changes of all the columns. I would be nice if columns 1 ... 3 have the same width. So column
0
1833
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 it's a Sharepoint WebPart. I'm trying to do something fairly simple, create a datagrid that displays where and when a person works and allows them to change some of the information via DropDownLists. When the user clicks to edit a row, three of...
1
2355
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 current cell to by: 'Get Screen Coorinate of Mouse Cursor Dim p As Point = New Point(dgrid.Parent.MousePosition.X,dgrid.Parent.MousePosition.Y) 'Convert Screen Coordinates to Local Coordinates Dim pC As Point = dgrid.PointToClient(p) 'Runs Hit...
3
1500
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 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...).
3
1711
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 Template Columns, into which I put buttons. When the user clicks on the 'Do It' button, the selection is recorded in an underlying database, and (almost) everything is fine. One thing I would like to improve in the existing version concerns...
0
9636
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.