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.

ListBoxSelectionMode=1 problem

Thread ID:

Created:

Updated:

Platform:

Replies:

11994 Mar 19,2004 05:14 AM Mar 23,2004 09:30 AM Windows Forms 9
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 19, 2004 05:14 AM

I have a virtual grid that works somewhat like the VirtTreeGrid sample. I have set the selection mode as follows: grid.ListBoxSelectionMode = SelectionMode.One; grid.ForceCurrentCellMoveTo = true; For some reason, the entire row is selected only when I use the mouse to click in a cell or when I move horizontally within the same row. As soon as I use the mouse to move to another row, the full-row selection stops working. If I start moving around in the new row, the cells I was on are painted using the "selected" color (i.e. with a gray background). I have been unable to figure out what''s causing this problem. I tried commenting out all the code that is executed in the QueryCellInfo handler, but that didn''t correct the problem. Any thoughts where I should look? By the way, I have two data-bound grids displayed at the same time, both using "One" as the ListBoxSelection mode. They work just fine. Thanks, Andy

Administrator [Syncfusion]
Replied On March 19, 2004 05:15 AM

I mis-stated part of the problem. The problem occurs only when I use the keyboard to move to another row. Using the mouse to click on another row works fine. Sorry for the confusion. >I have a virtual grid that works somewhat like the VirtTreeGrid sample. I have set the selection mode as follows: > >grid.ListBoxSelectionMode = SelectionMode.One; >grid.ForceCurrentCellMoveTo = true; > >For some reason, the entire row is selected only when I use the mouse to click in a cell or when I move horizontally within the same row. As soon as I use the mouse to move to another row, the full-row selection stops working. If I start moving around in the new row, the cells I was on are painted using the "selected" color (i.e. with a gray background). > >I have been unable to figure out what''s causing this problem. I tried commenting out all the code that is executed in the QueryCellInfo handler, but that didn''t correct the problem. > >Any thoughts where I should look? > >By the way, I have two data-bound grids displayed at the same time, both using "One" as the ListBoxSelection mode. They work just fine. > >Thanks, >Andy

Administrator [Syncfusion]
Replied On March 19, 2004 05:37 AM

I added ListBoxSelectionMode = SelectionMode.One to the VirtTreeGridSample, and did not have a problem moving the selected row with the arrow keys (using 2030). Are you handling any events that might affect the current cell activating or current cell moving? Can you modify the VirtTreeGrid sample to show the problem?

Administrator [Syncfusion]
Replied On March 19, 2004 08:52 AM

Clay, Here''s the setup for the grid in question. I''ve tried commenting out the handler for the CurrentCellMoved event. I''ve also commented out the code inside the QueryCellInfo handler. Still have the problem... this.browserGrid = new sfGrid.GridControl(); this.browserGrid.BeginInit ( ); this.browserGrid.Name="browserGrid"; this.browserGrid.Text="browserGrid"; this.browserGrid.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D; this.browserGrid.Size = new System.Drawing.Size(0,0); this.browserGrid.Dock = System.Windows.Forms.DockStyle.Fill; this.browserGrid.ColCount = 0; this.browserGrid.RowCount = 0; this.browserGrid.NumberedColHeaders = false; this.browserGrid.NumberedRowHeaders = false; this.browserGrid.Rows.HeaderCount = 1; this.browserGrid.Rows.FrozenCount = 1; this.browserGrid.ListBoxSelectionMode = SelectionMode.One; this.browserGrid.ForceCurrentCellMoveTo = true; this.browserGrid[-1,-1].ReadOnly = true; // the browser grid cells are non-editable at all times this.browserGrid.ResizeColsBehavior = (((Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.ResizeSingle | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.InsideGrid) | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.OutlineHeaders) | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.OutlineBounds); this.Controls.AddRange( new System.Windows.Forms.Control[] { this.browserGrid } ); this.browserGrid.CommandStack.Enabled = false; this.browserGrid.CellModels.Add ("TreeCellModel", new TreeCellModel(this.browserGrid.Model)); this.browserGrid.ResizingColumns += new sfGrid.GridResizingColumnsEventHandler(this.browserGrid_ResizingColumns); this.browserGrid.CellButtonClicked += new sfGrid.GridCellButtonClickedEventHandler(this.browserGrid_CellButtonClicked); this.browserGrid.QueryCellInfo += new sfGrid.GridQueryCellInfoEventHandler(GridQueryCellInfo); this.browserGrid.QueryRowCount += new sfGrid.GridRowColCountEventHandler(GridQueryRowCount); this.browserGrid.QueryRowHeight += new sfGrid.GridRowColSizeEventHandler(GridQueryRowHeight); this.browserGrid.QueryColCount += new sfGrid.GridRowColCountEventHandler(GridQueryColCount); this.browserGrid.QueryColWidth += new sfGrid.GridRowColSizeEventHandler(GridQueryColWidth); this.browserGrid.QueryCoveredRange += new sfGrid.GridQueryCoveredRangeEventHandler(GridQueryCoveredRange); this.browserGrid.CurrentCellMoved += new sfGrid.GridCurrentCellMovedEventHandler (GridCurrentCellMoved); >I added ListBoxSelectionMode = SelectionMode.One to the VirtTreeGridSample, and did not have a problem moving the selected row with the arrow keys (using 2030). > >Are you handling any events that might affect the current cell activating or current cell moving? > >Can you modify the VirtTreeGrid sample to show the problem?

Administrator [Syncfusion]
Replied On March 19, 2004 08:58 AM

I also modified the VirtTreeGrid sample but so far cannot figure out how to duplicate the problem in that sample. I guess if I could figure out how to duplicate it I would know what my problem was... >Clay, > >Here''s the setup for the grid in question. I''ve tried commenting out the handler for the CurrentCellMoved event. I''ve also commented out the code inside the QueryCellInfo handler. Still have the problem... > > >this.browserGrid = new sfGrid.GridControl(); >this.browserGrid.BeginInit ( ); >this.browserGrid.Name="browserGrid"; >this.browserGrid.Text="browserGrid"; >this.browserGrid.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D; >this.browserGrid.Size = new System.Drawing.Size(0,0); >this.browserGrid.Dock = System.Windows.Forms.DockStyle.Fill; >this.browserGrid.ColCount = 0; >this.browserGrid.RowCount = 0; >this.browserGrid.NumberedColHeaders = false; >this.browserGrid.NumberedRowHeaders = false; >this.browserGrid.Rows.HeaderCount = 1; >this.browserGrid.Rows.FrozenCount = 1; >this.browserGrid.ListBoxSelectionMode = SelectionMode.One; >this.browserGrid.ForceCurrentCellMoveTo = true; >this.browserGrid[-1,-1].ReadOnly = true; // the browser grid cells are non-editable at all times >this.browserGrid.ResizeColsBehavior = (((Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.ResizeSingle | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.InsideGrid) > | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.OutlineHeaders) > | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.OutlineBounds); > this.Controls.AddRange( new System.Windows.Forms.Control[] { this.browserGrid } ); > this.browserGrid.CommandStack.Enabled = false; > this.browserGrid.CellModels.Add ("TreeCellModel", new TreeCellModel(this.browserGrid.Model)); >this.browserGrid.ResizingColumns += new sfGrid.GridResizingColumnsEventHandler(this.browserGrid_ResizingColumns); >this.browserGrid.CellButtonClicked += new sfGrid.GridCellButtonClickedEventHandler(this.browserGrid_CellButtonClicked); >this.browserGrid.QueryCellInfo += new sfGrid.GridQueryCellInfoEventHandler(GridQueryCellInfo); >this.browserGrid.QueryRowCount += new sfGrid.GridRowColCountEventHandler(GridQueryRowCount); >this.browserGrid.QueryRowHeight += new sfGrid.GridRowColSizeEventHandler(GridQueryRowHeight); >this.browserGrid.QueryColCount += new sfGrid.GridRowColCountEventHandler(GridQueryColCount); >this.browserGrid.QueryColWidth += new sfGrid.GridRowColSizeEventHandler(GridQueryColWidth); >this.browserGrid.QueryCoveredRange += new sfGrid.GridQueryCoveredRangeEventHandler(GridQueryCoveredRange); >this.browserGrid.CurrentCellMoved += new sfGrid.GridCurrentCellMovedEventHandler (GridCurrentCellMoved); > > > >>I added ListBoxSelectionMode = SelectionMode.One to the VirtTreeGridSample, and did not have a problem moving the selected row with the arrow keys (using 2030). >> >>Are you handling any events that might affect the current cell activating or current cell moving? >> >>Can you modify the VirtTreeGrid sample to show the problem?

Administrator [Syncfusion]
Replied On March 19, 2004 09:03 AM

What happens if you comment out the QueryCoveredRange handler? If that does not affect this probelm, then try commenting out the this.browserGrid.ForceCurrentCellMoveTo = true; this.browserGrid[-1,-1].ReadOnly = true; // the browser grid cells are non-editable at all times lines.

Administrator [Syncfusion]
Replied On March 23, 2004 06:23 AM

I tried commenting out everything except for the 3 required handlers for a virtual grid (QueryCellInfo, ColCount, RowCount). I also commented out the normal handling of those messages and just had the col and row counts return 10 and the CellInfo handler just put the cell coordinate into the Style.Text field. The row-painting of the current row is still not working correctly. Interestingly, if I use the arrow-keys to move to the top of the grid and then hit the up arrow key one extra time, then the top row is highlighted correctly. The same happens if I move to the bottom of the grid. Pressing the down-arrow one extra time causes the last row to be highlighted. Very odd. I should point out that the grid control is actually wrapped inside a user-control-derived class. The wrapped class is then added to a tab-page. I created a new test app that creates the grid control inside a UserControl-derived class and then drops an instance of that class onto a tab page. The row selection works fine in the test app. Right now, I''m at a loss as to what the difference is between my app and the test app that would explain the strange row-selection behavior. >What happens if you comment out the QueryCoveredRange handler? > >If that does not affect this probelm, then try commenting out the > >this.browserGrid.ForceCurrentCellMoveTo = true; >this.browserGrid[-1,-1].ReadOnly = true; // the browser grid cells are non-editable at all times > >lines.

Administrator [Syncfusion]
Replied On March 23, 2004 06:25 AM

Clay, Should I move this discussion over to Direct-Trac? I''m not sure that the problem I''m seeing (or it''s resolution) is particularly useful to anyone else. Also, I''m wondering if you would be willing to take at look at the problem via a Placeware session that I could set up so you could see what''s happening first hand. Thanks, Andy >I tried commenting out everything except for the 3 required handlers for a virtual grid (QueryCellInfo, ColCount, RowCount). I also commented out the normal handling of those messages and just had the col and row counts return 10 and the CellInfo handler just put the cell coordinate into the Style.Text field. > >The row-painting of the current row is still not working correctly. > >Interestingly, if I use the arrow-keys to move to the top of the grid and then hit the up arrow key one extra time, then the top row is highlighted correctly. The same happens if I move to the bottom of the grid. Pressing the down-arrow one extra time causes the last row to be highlighted. Very odd. > >I should point out that the grid control is actually wrapped inside a user-control-derived class. The wrapped class is then added to a tab-page. > >I created a new test app that creates the grid control inside a UserControl-derived class and then drops an instance of that class onto a tab page. The row selection works fine in the test app. Right now, I''m at a loss as to what the difference is between my app and the test app that would explain the strange row-selection behavior. > > >>What happens if you comment out the QueryCoveredRange handler? >> >>If that does not affect this probelm, then try commenting out the >> >>this.browserGrid.ForceCurrentCellMoveTo = true; >>this.browserGrid[-1,-1].ReadOnly = true; // the browser grid cells are non-editable at all times >> >>lines.

Administrator [Syncfusion]
Replied On March 23, 2004 07:39 AM

Is the problem strictly a refresh problem? ie., When you do not correctly see the selection, if you drag the window off/on the screen so the grid is forced to repaint, it paints the selection properly. If so, you might try setting grid.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow; Remote debugging is generally considered consulting, and would have to be arranged through sales. Feel free to open a Direct Trac incident, but without a sample showing the problem, it will be difficult to home in on what is causing this behavior.

Administrator [Syncfusion]
Replied On March 23, 2004 09:30 AM

Clay, I finally figured out what the problem was. At the beggining of where I set a bunch of properties for the grid control, I do a BeginInit(). But somewhere along the line, the EndInit() call got deleted. Once I corrected that, the problem went away. >Is the problem strictly a refresh problem? ie., When you do not correctly see the selection, if you drag the window off/on the screen so the grid is forced to repaint, it paints the selection properly. > >If so, you might try setting > >grid.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow; > > >Remote debugging is generally considered consulting, and would have to be arranged through sales. > >Feel free to open a Direct Trac incident, but without a sample showing the problem, it will be difficult to home in on what is causing this behavior. > >

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.

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.

;