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.

Force a Grid to be 2x2

Thread ID:

Created:

Updated:

Platform:

Replies:

45883 Jun 29,2006 04:35 PM Jun 29,2006 05:33 PM Windows Forms 1
loading
Tags: GridControl
Michael Scott
Asked On June 29, 2006 04:35 PM

I''m trying to change the size of a grid to a single cell (ncluding row/col borders) if there is no data, but it isn''t working. What is wrong with this code (what am I missing) : if (numDefects == 0) { this.gridCtl.BeginUpdate(); int [,] grid = new int[2, 2]; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) grid[i,j] = 0; this.gridCtl.Model.PopulateValues( GridRangeInfo.Cells(0, 0, 2, 2), grid ); this.gridCtl.EndUpdate(); this.gridCtl.Refresh(); this.gridCtl.Invalidate(); return; }

Administrator [Syncfusion]
Replied On June 29, 2006 05:33 PM

Hi Michael, The Populate method gives you an easy way to copy the data from any given datasource that implements the IList interface or is an Array to the specified range of cells in the Grid. It doesn''t configure the grid (ie it doesn''t set the RowCount/ColCount/Style property of the grid). If you want to configure the grid, you can set those property explictly. Here is a code snippet. if (numDefects == 0) { this.gridCtl.BeginUpdate(); int [,] grid = new int[2, 2]; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) grid[i,j] = 0; this.gridCtl.Model.PopulateValues( GridRangeInfo.Cells(0, 0, 2, 2), grid ); //Set the RowCount AND Colcount this.gridCtl.RowCount = 1; this.gridCtl.ColCount = 1; this.gridCtl.EndUpdate(); this.gridCtl.Refresh(); this.gridCtl.Invalidate(); return; } Let me know if this helps, Best Regards, Haneef

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.

;