We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Colwidth and extra space on scrolled to right grid

Thread ID:

Created:

Updated:

Platform:

Replies:

20219 Oct 12,2004 04:34 PM UTC Nov 12,2004 07:48 AM UTC Windows Forms 11
loading
Tags: GridControl
Philip Bishop
Asked On October 12, 2004 04:34 PM UTC

Hey Im having a problem getting rid of the DEAD space at the right of my grid. I thought we had this down to a calculation by taking the number of columns u want displayed without scrolling times each one of those cols width. then u add in the col header width and add 18. thats how big we have figured out the grid needs to be width wise for no dead space on the right when its scrolled all the way to the right. i''ve recently started doing forms where say the first col is a diff width then the other say 32 in this example i am sending. using that calculation i can never get rid of the dead space at the right. so we''ve figured out that its because of having one col width diff then the others. Why?? So we had the idea of freezing that header cell and that seems to fix the problem but introduces another. if u run my sample u will notice the dead space at the right when u scroll. if u uncomment out the frozen line in the load paragraph u will notice the dead space is gone but u will aslo now notice that the right line of col 1 that is separting it and col 2 has been changed to BLUE. now in testing we''ve decided we make like that first col frozen anyway which fixes the dead space but we dont like the blue line. so can u tell me why the blue line is happening and what i can do to fix it and why if i dont want to use frozen why cant i ever get rid of dead space on a grid where one cell width of a col might be diff then every other col width size Thanks Phil colwidthtest_779.zip

Administrator [Syncfusion]
Replied On October 12, 2004 06:34 PM UTC

Hi Phil, try the following lines of code: Me.grdSC_GSC.Model.Cols.FrozenCount = 1 Me.grdSC_GSC.Model.ColStyles(1).Borders.Right = New GridBorder(GridBorderStyle.Solid, Me.grdSC_GSC.Model.Properties.FixedLinesColor) Me.grdSC_GSC.HScrollPixel = True Stefan

Philip Bishop
Replied On October 13, 2004 10:00 AM UTC

Ok that didnt work. Its still blue and that code u had me try also made it scroll kinda funny as opposed to not adding those extra lines. Whats going on with this, and how can i fix it BOTH ways. Meaning having it frozen and no blue line and not having it frozen and NOT having the dead space at the right???????

Administrator [Syncfusion]
Replied On October 13, 2004 03:42 PM UTC

I am having trouble seeing the behavior in your samples. I get exceptions trying to load the colwidths you have saved using the designer, so I only can see the defaults. The only thing I can see is the extra thick fixed line where you have the frozen column. Here is code that displays a standard grid line for me in your sample at that point. Me.grdSC_GSC.Model.Cols.FrozenCount = 1 ''get the color you are using for your gridlines Dim lineCol As Color = Me.grdSC_GSC.Properties.GridLineColor Me.grdSC_GSC.Properties.FixedLinesColor = Color.FromArgb(0, Color.Red) Me.grdSC_GSC.Model.ColStyles(1).Borders.Right = New GridBorder(GridBorderStyle.Solid, lineCol) If you can resend your sample without setting any colwidths in the designer, maybe I can see your exact problem and offer a better suggestion.

Administrator [Syncfusion]
Replied On October 13, 2004 03:48 PM UTC

Hi Phil, this is the complete code for Form_Load Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.grdSC_GSC.Model.CutPaste.ClipboardFlags += GridDragDropFlags.NoAppendRows + GridDragDropFlags.NoAppendCols - GridDragDropFlags.Styles Me.grdSC_GSC.Model.RowHeights(0) = 50 Me.grdSC_GSC.Model.ColWidths(0) = 75 Dim i, j As Integer For i = 1 To 128 For j = 2 To 32 grdSC_GSC(i, j).CellValue = 201 + i Next Next Dim showFrozen As Boolean = True If showFrozen Then '' Show a frozen line without a blue border (explicitly turning off that border below) Me.grdSC_GSC.Model.Cols.FrozenCount = 1 Me.grdSC_GSC.Model.ColStyles(1).Borders.Right = New GridBorder(GridBorderStyle.Solid, Me.grdSC_GSC.Model.Properties.GridLineColor) Me.grdSC_GSC.HScrollPixel = True Else '' Show no frozen line Me.grdSC_GSC.Model.Cols.FrozenCount = 0 Me.grdSC_GSC.HScrollPixel = True End If grdSC_GSC.Visible = True End Sub You can toggle the showFrozen variable in order to show or not show frozen columns. A key line in the code above is usage of horizontal pixel scrolling. This lets the grid ensure no grey area will be displayed after the last column. I also attached form1.vb with my changes. Stefan Form1_6214.zip

Philip Bishop
Replied On October 13, 2004 04:04 PM UTC

Ok I cant make it happen on a new form. Thats why i sent you one of the like 10 that are similar that its doing it on. I have colwidth set to 70 in col one and then 95 in all the other cols..so i set thet default width to 95 then go back and change the one col width in col1 to 70. I am attaching a picture of what i see. If you cant make this work, can u tell me how i can get rid of the dead space on the right when u have one col width diff then the others?? we could probably live with that. i will work on getting a new grid and going line by line and making sure the values are the same as the one i sent you. Screen02_1939.zip

Philip Bishop
Replied On October 13, 2004 04:13 PM UTC

ok im attaching another grid where i reset all the default col widths and it still does it. i just noticed a sample from stefan now as i was posting this that must of came right after clays message. im going to look in to his response now let me know if u see it here on this one colwidthtest1_8210.zip

Philip Bishop
Replied On October 13, 2004 04:34 PM UTC

ok so in further testing of stefans last post it seems to fix the problem both ways. however when u are freezing the colum u DONT want to use that hscrollpixel=true line. thats the line i just figured out is the line that causes it to scroll funny when u have a frozen header. Ok so my last question i guess is what does that hscrollpixel=true do? How does that prevent me from having dead space on the right and does that always hold true that it will always kill the dead space on the right?? Like i said in the past we''ve always just added up the displayed col width sizes and the header col width size and then added 18 and it worked. what does that do?

Administrator [Syncfusion]
Replied On October 13, 2004 07:05 PM UTC

Setting HPixelScroll = true allows the grid to scroll pixel by pixel (as opposed to column by column). This means it is not required that the left most scrollable column is not required to be fully visible and that the right most column will end exactly at the right edge of the grid''s client area. Without pixel scrolling, the scrollable width of the grid (the clientarea.width) must always be exactly the width of the last few visible columns (the exact number depends upon the number of columns). If you are off by a pixel, you see the extra space because the left most column must be fully visible without the pixel scrolling. If you do not want to use the pixel scrolling, another solution is to handle the QueryColWith event. In that event, when e.Index is the last column, then set e.Size to be the exact number of pixels to fill the cleintarea.width.

Administrator [Syncfusion]
Replied On October 13, 2004 07:19 PM UTC

Here is a handler that seems to work in your sample without the pixel scrolling sample.
Private Sub grdSC_GSC_QueryColWidth(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs) Handles grdSC_GSC.QueryColWidth
        If e.Index = Me.grdSC_GSC.ColCount Then
            Dim w As Integer = Me.grdSC_GSC.ColWidths.GetTotal(0, Me.grdSC_GSC.Cols.FrozenCount) + Me.grdSC_GSC.ColWidths.GetTotal(Me.grdSC_GSC.LeftColIndex, Me.grdSC_GSC.ColCount - 1)
            e.Size = Math.Max(0, Me.grdSC_GSC.ClientSize.Width - w)
            e.Handled = True
        End If
    End Sub

Philip Bishop
Replied On November 10, 2004 01:11 PM UTC

Ok all of the above u gave me was working fine. Just lately a tester noticed something and wanted to know if it could be fixed. The sample im attaching which is the same sample i had in above post with only one line change to get rid of the BLUE it seems to have a problem now scrolling. The issue is when u grab hold of the first cell with ur mouse and then try and drag to the right with the mouse to select the row. When u do this u will notice that it stops at the last visible col on the screen and wont let u select past that. If u click on the cell and then hold down ur shift key and arrow over it will let u go past this col and select all of the data. This has only started happening after we added the frozen count to freeze that first col. Any reason why i can select all the row with the shift and the keyboard but i cant with the mouse?? colwidthtest3_4633.zip

Administrator [Syncfusion]
Replied On November 12, 2004 07:48 AM UTC

This is by design. There is explicit code in the selection mouse controller that does not allow you to auto scroll if the selections start in a frozen cell. The thought is that if you scroll in this situation, you will no longer display contiguous selected cells (and if the selection actually begin with the grid scrolled, you user. Here is the code in GridDragSelectMouseController.LefMouseDown.
if (hitTestInfo.colSelected && !Grid.InternalIsFrozenCol(colIndex))
{
	dx = Grid.ViewLayout.GetColRangeWidth(0, Grid.InternalGetFrozenCols(), GridCellSizeKind.VisibleSize);
	ab |= ScrollBars.Horizontal;
}
Grid.AutoScrolling = ab;
So autoscrolling is only enabled if your start cell in not frozen. So, if you want to change this behavior, you can do your own GridDragSelectMouseController and replace this code. I am not sure what implications enabling auto scrolling that starts on a frozen cell might have for other grid behaviors. It would have to be tested. I will discuss this with Stefan to see if he knows any specific functionality that might break if you remove this check. Your tester can get the same results as autoscrolling by clicking the frozen cell, then scrolling the grid, and finally shift clicking the terminal cell.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;