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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

highlighting a row

Thread ID:





43201 Apr 18,2006 01:45 PM UTC Apr 19,2006 04:11 PM UTC WinForms 5
Tags: GridControl
Philip Bishop
Asked On April 18, 2006 01:45 PM UTC

I am making a grid that has checkbox''s in all the cells in col 0. I want to know how I can make it so that when the user clicks one of the checkboxes the row will be highlighted. If they click another row then that row will also be highlighted. The only way the rows become un-highlighted is by uncheciking the checkbox in col 0 for that row. So they could have multiple rows highlighted all over the grid. So bascially you check the box and the row is selected and when its unchecked its unselected. Is there a way I can go about this?

Administrator [Syncfusion]
Replied On April 19, 2006 04:57 AM UTC

Hi Philip, Could you try this code //Model''s QueryCellInfo Event. if(e.RowIndex > 0 && e.ColIndex > 0) { int colIndex = this.gridDataBoundGrid1.NameToColIndex("CheckBox"); bool cellValue = (bool)this.gridDataBoundGrid1.Model[e.RowIndex,colIndex].CellValue; if(cellValue) { e.Style.BackColor = Color.PowderBlue; } } //Grid''s CurrentcellChanged event GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; if(cc.Renderer.StyleInfo.CellType == "CheckBox") { this.gridDataBoundGrid1.CurrentCell.ConfirmChanges(); this.gridDataBoundGrid1.RefreshRange(GridRangeInfo.Row(cc.RowIndex)); } Here is a sample. http://www.syncfusion.com/Support/user/uploads/GDBG_Check_d2e8f073.zip Please let me know if you need any further assistance. Thanks for choosing Syncfusion Products. Regards, Haneef

Administrator [Syncfusion]
Replied On April 19, 2006 01:24 PM UTC

Thanks for the reply. Can you make your sample work with the checkboxes in the header col? In my previous post I said I was working with col 0, but forgot to say it was the header cell. So I have checkboxes in the HEADER COL 0. We messed with setting the backcolor and its doesnt seem to work the same when its in the header col. Is this the only way we can do this is by changing the color? Cant we just use the selection bar that comes up when you click the header col now? Also if you have more sample code is there any chance I can get it in VB? Oh and lastly we arent using data bound grids if that makes a difference. Thanks.

Administrator [Syncfusion]
Replied On April 19, 2006 02:19 PM UTC

Hi Philip, Sorry for the inconvenience caused. Could you this code in QueryCellInfo Event If e.RowIndex > 0 AndAlso e.ColIndex > 0 Then Dim cellValue As Boolean = CBool(Me.gridControl1.Model(e.RowIndex,0).CellValue) If cellValue Then e.Style.BackColor = Color.PowderBlue End If End If Here is a modified sample. http://www.syncfusion.com/Support/user/uploads/VB_c5f6bdd8.zip Please let me know if you need any further assistance. Regards, Haneef

Administrator [Syncfusion]
Replied On April 19, 2006 03:07 PM UTC

Ok that seems to work but its still not highlighting the header cell that has the checkbox in it. In the grid im trying to do this on it has mulitp cols that are frozen header cells. I want all of the cells in cluding the check box to be highlighted or have the color changed on it. Thanks

Administrator [Syncfusion]
Replied On April 19, 2006 04:11 PM UTC

Hi Philip, This can also be done by just handling the PrepareViewStyleInfo event. Attached is the modified sample. Let us know if this helps. Regards, Calvin.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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