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

How to redraw a single Grid Row?

Thread ID:

Created:

Updated:

Platform:

Replies:

9791 Jan 12,2004 08:58 AM UTC Jun 13,2007 05:08 PM UTC Windows Forms 9
loading
Tags: GridControl
Nick Pasko
Asked On January 12, 2004 08:58 AM UTC

The point is to change the Row''s Font settings to Bold. If i just set m_oGrid.RowStyles[i].Font = oFont; where oFont is new Font with oFont.Bold = true it won''t refresh, the text in all row''s cells is still not bold. If i call m_oGrid.Refresh(), m_oGrid.Update, m_oGrid.Invalidate() - that won''t do anything. It works only when i recreate Grid contents manually - set it''s RowCount to 0, then back to m_nRowCount and fill all data again. But i need to do it quick, not losing time to refilling the grid cells. How do i do this?

Administrator [Syncfusion]
Replied On January 12, 2004 11:09 AM UTC

Your grid is a GridControl, correct? If so, you can change a row style and then call grid.RefreshRange to only refresh the passed in range. (or, you can call grid.Refresh() to refresh everything.) But if your grid is a GridDataBoundGrid, then it does not have rowstyles. Instead you have to use the PrepareViewStyleInfo event to handle such things (in addition to calling grid.RefreshRange). See this KB. http://www.syncfusion.com/Support/article.aspx?id=561

Nick Pasko
Replied On January 14, 2004 08:28 AM UTC

>Your grid is a GridControl, correct? Exactly. >If so, you can change a row style and then call grid.RefreshRange to only refresh the passed in range. (or, you can call grid.Refresh() to refresh everything.) It does not redraw. I don''t know exactly why, but suppose it is somehow connected with applying RowStyle settings only after recreating the row, because if i rebuild the grid totally it does apply the Font settings.

Administrator [Syncfusion]
Replied On January 14, 2004 10:06 AM UTC

I do not have the problem you are describing when I use either set of code below from a button handler to set the font to bold in a GridControl (using version 2.0.2.0). Here is a sample project. What is different about what you are doing? Can you attach a sample project showing the problem? ////this code works... //GridStyleInfo style = this.gridControl1.RowStyles[2]; //style.Font.Bold = true; //style.BackColor = Color.LightGoldenrodYellow; //so does this GridFontInfo font = new GridFontInfo(); font.Bold = true; this.gridControl1.RowStyles[2].Font = font;

Administrator [Syncfusion]
Replied On January 15, 2004 02:32 AM UTC

private void m_oGrid_CellClick(object sender, GridCellClickEventArgs e) { //Some code goes here //..... this.ShowNewGridMsg(e.RowIndex, false); //Update the row Font //A little bit of code goes here } private void foo(int nRow, bool bBold) { GridFontInfo oFont = new GridFontInfo(); oFont.Bold = bBold; this.m_oGrid.RowStyles[nRow].Font = oFont; //Change the grid row Font Syncfusion.Windows.Forms.Grid.GridRangeInfo oRange = new GridRangeInfo(); // I tried these 3 lines in any order and combination - // no result though // this.m_oGrid.Invalidate(); // this.m_oGrid.Update(); // this.m_oGrid.Refresh(); } foo method is called from GridCell_Click event handler, as well as from method bar, the differences are: 1) GridCell_click is a Grid event handler, while bar is called form another control event handler, say TreeView 2) method bar first calls method ClearGrid: private void ClearGrid(int nRowCnt) { Thread.Sleep(0); this.m_oGrid.RowCount = 0; this.m_oGrid.RowCount = nRowCnt; } to clear the grid and set it''s RowCount anew. 3) method bar fills every single Row, calling method foo if needed, while GridCell_click does not change the Row content I hope that would help to recognize the problem.

Administrator [Syncfusion]
Replied On January 15, 2004 08:21 AM UTC

You can try the following but I do not know if they will have any effect: private void ClearGrid(int nRowCnt) { Thread.Sleep(0); this.m_oGrid.RowCount = 0; this.m_oGrid.RowCount = nRowCnt; this.m_oGrid.ResetVolatileData(); //added } private void foo(int nRow, bool bBold) { this.m_oGrid.Focus(); GridFontInfo oFont = new GridFontInfo(); oFont.Bold = bBold; this.m_oGrid.RowStyles[nRow].Font = oFont; this.m_oGrid.RefeshRange(GridRangeInfo.Row(nRow), true); } If you are looping through something filling the grid row by row, is it some kind of tight loop that precludes message processing? If so, you might try adding an Application.DowEvents call to see if that allows the painting to show up. If you cannot get this resolved, the quickest way for us to be of help is if you attach a sample project showing the problem. (Or, you can submit a Direct Trac support incient with the sample).

Nick Pasko
Replied On February 25, 2004 09:39 AM UTC

allright, now i''ve ran into this bug again.. i made a test project - a single form with a GridControl (5 rows, 5 columns) and two buttons on it. here goes the code for both button handlers: private void button1_Click(object sender, System.EventArgs e) { GridFontInfo oFont = new GridFontInfo(); oFont.Bold = true; this.oGrid.RowStyles[2].Font = oFont; this.oGrid.RefreshRange(GridRangeInfo.Row(2), true); } private void button2_Click(object sender, System.EventArgs e) { GridFontInfo oFont = new GridFontInfo(); oFont.Bold = false; this.oGrid.RowStyles[2].Font = oFont; this.oGrid.RefreshRange(GridRangeInfo.Row(2), true); } When you click the first button, it works properly - font becomes bold at once, all is well. But when you click the second button, font does not change at all. What''s the problem with it??

Administrator [Syncfusion]
Replied On February 25, 2004 09:43 AM UTC

Wow, seems i have solved it. ^^ Well, as far as i see, the first change goes pretty fine, but if i assign oGrid.Rowstyles[2].Font a new value - it does not work at all. But assigning directly oGrid.RowStyles[2].Font.Bold = false works pretty fine. Damn that is unusual :P

Raul
Replied On June 13, 2007 10:56 AM UTC

Hi,

Hw do i set Row styles for a DGBG?

haneefm [Syncfusion]
Replied On June 13, 2007 05:08 PM UTC

Hi Rahul,

By default, DataBoundGrid doesn't store any style info properties. You can not set any cell or row specific properties for the DataBoundGrid using Model Indexer other than the CellValue. You need to handle the PrepareViewStyleInfo (or Model.QueryCellInfo) Event to do this. Through this event you can set the style properties for the grid.

To set the BackColor for a cell, you check for the e.RowIndex/e.ColIndex, if that points to the row you desired, set the e.Style.BackColor for it.

If you want to set the cell style property in a grid then call the Refresh or RefreshRange method to fire the QueryCellInfo event to set the style settings of the cell in a grid.

See the KnowledgeBase Articles for more info.
QueryCellInfo event : http://www.syncfusion.com/Support/article.aspx?id=10351
PrepareViewStyleInfo event :http://www.syncfusion.com/Support/article.aspx?id=560

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.

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

;