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.

One place for all formating

Thread ID:

Created:

Updated:

Platform:

Replies:

14694 Jun 2,2004 10:44 AM Jun 8,2004 03:32 PM Windows Forms 15
loading
Tags: GridControl
Vivek
Asked On June 2, 2004 10:44 AM

Hi, What is the best way and where ( I mean which event) to change row height, column width, cell back color …..? I want to know where should i do all sort of formaing like cell style, column width, row hieght and setting cell cover property dynamically. I am using a GridControl. Thanks

Administrator [Syncfusion]
Replied On June 2, 2004 11:10 AM

There are different events for the different properties you mentioned. cell styles - PrepareViewStyleInfo row heights - QueryRowHeight col widths - QueryColWidth covered cells - QueryCoveredCells You can use these events to dynamically set values. Now if the behavior you need is more derterministic (meaning you change some value and store it in the grid, and then based on this value, you set a row height or set a column width), then there are other events (maybe CurrentCellConfirmChanges) where you could one time make the change. But if you want to do things dynamically (or are using the GridControl in virtual mode) then you would need to catch the other events listed above.

Vivek
Replied On June 2, 2004 01:12 PM

Thanks for yur reply. I need to do this dynmic formatting based on some user action/input. user action are out of Grid control. let say user checked/Unchecked some checkboxes and based on these selection, basically as soon as user check/Unchecked check box I i need to do grid formatting(hide/show row columns, style, covered cells). Do i have to some how trigger the grid''s event on the click event of check box? OR how would i force a grid to fire all the event suggested by you on click event of a check box? please do reply! thanks

Administrator [Syncfusion]
Replied On June 2, 2004 02:02 PM

Normally, to trigger these dynamic events, you force the grid to redraw all or part of itself by calling either grid.Refresh or grid.RefreshRange. This normally makes teh grid redraw and reflect the new values.

Administrator [Syncfusion]
Replied On June 3, 2004 03:00 PM

Hi, Could you please provide the little code sample to use QueryCoveredCells to cover multiple cell at multiple location? Or How would I achieve the following in QueryCoveredCells event ? programGrid.Model.CoveredRanges.Add(GridRangeInfo.Cells(11,0,12,0)); programGrid.Model.CoveredRanges.Add(GridRangeInfo.Cells(13,0,14,0)); programGrid.Model.CoveredRanges.Add(GridRangeInfo.Cells(15,0,16,0)); programGrid.Model.CoveredRanges.Add(GridRangeInfo.Cells(17,0,18,0)); GridStyleInfo rowStyle = new GridStyleInfo(); rowStyle.CellType = "Static"; rowStyle.BackColor = Color.BurlyWood; rowStyle.HorizontalAlignment = GridHorizontalAlignment.Center; rowStyle.VerticalAlignment = GridVerticalAlignment.Middle; rowStyle.Font.Size = 7; rowStyle.Font.Bold = true; programGrid.ChangeCells(GridRangeInfo.Cells(11, 0, 18, 0), rowStyle);

Administrator [Syncfusion]
Replied On June 3, 2004 03:23 PM

Here is a sample. forum_sample_5999.zip Normally, if you only have a few coveredcells, you just explicitly add them to the grid.Coveredranges collection. QueryCoveredRanges is normally used for repeating patterns of multiple covered cells (as shown in the sample code) but can be used to set explicit covered cells as well.

Administrator [Syncfusion]
Replied On June 4, 2004 01:38 PM

Hi I have the following code written in the QueryCoveredRange event. if(e.RowIndex == 0 && e.ColIndex > 0) { if(e.ColIndex % 2 == 1) { e.Range = GridRangeInfo.Cells0 ,e.ColIndex,0,e.ColIndex+1); this.programGrid[0,1].Text ="Total"; this.programGrid[0,3].Text ="03/01/2004"; this.programGrid[0,5].Text ="03/02/2004"; this.programGrid[0,7].Text ="03/03/2004"; } } When i ran it it gave me following error. "An unhandled exception of type ''System.StackOverflowException'' occurred in syncfusion.grid.dll" Help Vivek

viveks
Replied On June 4, 2004 02:59 PM

>Hi > >I have the following code written in the >QueryCoveredRange event. > >if(e.RowIndex == 0 && e.ColIndex > 0) >{ >if(e.ColIndex % 2 == 1) >{ >e.Range = GridRangeInfo.Cells0 ,e.ColIndex,0,e.ColIndex+1); >this.programGrid[0,1].Text ="Total"; >this.programGrid[0,3].Text ="03/01/2004"; >this.programGrid[0,5].Text ="03/02/2004"; >this.programGrid[0,7].Text ="03/03/2004"; > } > >} > >When i ran it it gave me following error. > >"An unhandled exception of type ''System.StackOverflowException'' occurred in syncfusion.grid.dll" > >Help >Vivek Hi clay Just the continuation of last entry If i remove the following lines from my code this.programGrid[0,1].Text ="Total"; this.programGrid[0,3].Text ="03/01/2004"; this.programGrid[0,5].Text ="03/02/2004"; this.programGrid[0,7].Text ="03/03/2004"; It works fine I have to set thesed value in the grid Please suggest if i can do this in the QueryCoveredRange event or i have to do it somewhere else. Thanks Vivek

Administrator [Syncfusion]
Replied On June 4, 2004 04:13 PM

If this is a GridControl and the values are fixed, and do not change as your program executes, then set them in FormLoad. You normally use these events to manage data that is dynamic. But if you are using fixed data in a GridControl, you can just set it once and be done with it. If you are using a GridDataBoundGrid, then you would want to set e.Style.Text to be some value (like "03/03/2004") based on what e.ColIndex and e.RowIndex are (e.ColIndex == 1 && e.RowIndex == 0).

Administrator [Syncfusion]
Replied On June 4, 2004 05:17 PM

In my previous post, I forgot to say where the last code snippet could be used. That comment is in reference to code that you can use in the PrepareViewStyleInfo event. >>If you are using a GridDataBoundGrid, then you would want to set e.Style.Text to be some value (like "03/03/2004") based on what e.ColIndex and e.RowIndex are (e.ColIndex == 1 && e.RowIndex == 0).

Administrator [Syncfusion]
Replied On June 4, 2004 06:59 PM

Thanks clay, I am using GridControl control and values are not fixed. i have to change then some time. where should i set these values? please help. thanks

Administrator [Syncfusion]
Replied On June 4, 2004 11:44 PM

You have two options, setting them in some event or setting them with the indexer when they change. To set them in an event, you can use PrepareViewStyleInfo just as in a GridDataBoundGrid.
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.RowIndex == 0 && e.ColIndex > 0)
	{
		switch(e.ColIndex)
		{
			case 1:
				e.Style.Text = "03/01/2004";
				break;
			case 2:
				e.Style.Text = "04/01/2004";
				break;
			case 3:
				e.Style.Text = "05/01/2004";
				break;
			default:
				break;
		}
	}
}
Or, if you know when the values change (ie, if you explicitly change them in code or if some event is fired when they change), then you just set them using the indexer in code at that point just like you would in FormLoad to set them initially.

viveks
Replied On June 7, 2004 09:19 AM

Clay if you could you please reply to the question i posted on friday 06/04/2004 (Reg. QueryCoveredRange event) I would realy appreciate that. I am kind of stuck with the problem. Thanks > > >>Hi >> >>I have the following code written in the >>QueryCoveredRange event. >> >>if(e.RowIndex == 0 && e.ColIndex > 0) >>{ >>if(e.ColIndex % 2 == 1) >>{ >>e.Range = GridRangeInfo.Cells0 ,e.ColIndex,0,e.ColIndex+1); >>this.programGrid[0,1].Text ="Total"; >>this.programGrid[0,3].Text ="03/01/2004"; >>this.programGrid[0,5].Text ="03/02/2004"; >>this.programGrid[0,7].Text ="03/03/2004"; >> } >> >>} >> >>When i ran it it gave me following error. >> >>"An unhandled exception of type ''System.StackOverflowException'' occurred in syncfusion.grid.dll" >> >>Help >>Vivek > > >Hi clay > >Just the continuation of last entry >If i remove the following lines from my code > >this.programGrid[0,1].Text ="Total"; >this.programGrid[0,3].Text ="03/01/2004"; >this.programGrid[0,5].Text ="03/02/2004"; >this.programGrid[0,7].Text ="03/03/2004"; > >It works fine >I have to set thesed value in the grid >Please suggest if i can do this in the QueryCoveredRange event or i have to do it somewhere else. > >Thanks >Vivek >

Administrator [Syncfusion]
Replied On June 7, 2004 09:36 AM

I am sorry, I thought I had responded. >>Please suggest if i can do this in the QueryCoveredRange event or i have to do it somewhere else. You have to do it some other place. The response immediately following the original post was trying to tell you where you need to do it. Here is what I posted there. <>If you are using a GridDataBoundGrid, then you would want to set e.Style.Text to be some value (like "03/03/2004") based on what e.ColIndex and e.RowIndex are (e.ColIndex == 1 && e.RowIndex == 0). >>

viveks
Replied On June 8, 2004 02:57 PM

Clay Can we change the background color of a cell in CellDrawn event of the Grid. I have tried the following e.Style.BackColor = Color.Red; and its not working. Can you please suggest. Thanks >I am sorry, I thought I had responded. > >>>Please suggest if i can do this in the QueryCoveredRange event or i have to do it somewhere else. > >You have to do it some other place. > > > >The response immediately following the original post was trying to tell you where you need to do it. Here is what I posted there. > >< >You normally use these events to manage data that is dynamic. But if you are using fixed data in a GridControl, you can just set it once and be done with it. > >If you are using a GridDataBoundGrid, then you would want to set e.Style.Text to be some value (like "03/03/2004") based on what e.ColIndex and e.RowIndex are (e.ColIndex == 1 && e.RowIndex == 0). > > > > > By Clay Burch at 6/4/2004 5:17:12 PM > > >In my previous post, I forgot to say where the last code snippet could be used. That comment is in reference to code that you can use in the PrepareViewStyleInfo event. > >>>If you are using a GridDataBoundGrid, then you would want to set e.Style.Text to be some value (like "03/03/2004") based on what e.ColIndex and e.RowIndex are (e.ColIndex == 1 && e.RowIndex == 0). > > >>

Administrator [Syncfusion]
Replied On June 8, 2004 03:32 PM

The cell is already drawn in the CellDrawn event so setting e.Style.BackColor there will have no effect on what the grid will draw. To set the backcolor dynamically, you should do it in PrepareViewStyleInfo which is hit before the grid tries to draw the 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.

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.

;