|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datagrid Multiple SelectI want from the datagrid is to select (highlight) the entire row when I click on any cell in a row. I have done this using code from syncfuson.com to create a class that inherits from DataGridTextBoxColumn and overrides the its Edit method. i.e. Public Class DataGridNoActiveCellColumn Inherits DataGridTexBoxColumn Private SelectedRow as Integer Protected Overloads Overrides Sub Edit (ByVal source As CurrencyManager, ByVal rowNum as Integer...) SelectedRow = rowNum If (SelectedRow > -1) and (SelectedRow < source.List.Count) then Me.DataGridTableStyle.DataGrid.Unselect(SelectedRow) Me.DataGridTableStyle.DataGrid.Select(SelectedRow) End if End Sub End Class This works well. For certain grids, I want the user to be able to select more than one row, and each selected row to be highlighted. To attempt to do this I created another class similar to the above, but without the Me.DataGridTableStyle.DataGrid.Unselect(SelectedRow) line, and created my DataGridTableStyle using that, but it didn't work. How can I highlight multiple rows at the same time in a .NET datagrid? Thanks in advance. Andy Baker The KB where the above code came from (with a slightly different order
of statement - need to unselect the old one before you assign the row number) has a solution to also handle multiple selections. http://www.syncfusion.com/faq/windowsforms/search/856.aspx ====================== Clay Burch Syncfusion, Inc. Hello Clay
Thanks for that. I think I understand the theory, but unfortunately I cannot download the sample project from that address - I get a 404 error, file not found. I have created a class DataGridMultipleSelectColumn that inherits from DataGridTextBoxColumn, that consists of a single sub: Protected Overloads Overrides Sub Edit(ByVal source as CurrencyManager...) End Sub with an empty method. This prevents the clicked cell from being selected, as I would expect. I have then created a class inheriting from Windows.Forms.Datagrid and added a boolean property AllowMultipleSelection. I then override the OnMouseDown Event as follows: Protected Overloads Overrides Sub OnMouseDown(ByVal e as MouseEventArgs) Dim aHitTestInfo as DataGrid.HitTestInfo aHitTestInfo = Me.HitTest(New Point (e.X, e.Y)) If (aHitTestInfo.Type = Me.HitTestType.Cell and AllowMultipleSelection) then MyBase.OnRowHeaderClick(e) End if End Sub However, this doesn't select the row. Is it because OnMouseDown takes an argument of type MouseEventArgs and OnRowHeaderClick takes an argument of EventArgs, and if so how do I convert between them? Thanks for your help. Andy Baker Show quoteHide quote "ClayB" <cl***@syncfusion.com> wrote in message news:1178204623.414154.140030@h2g2000hsg.googlegroups.com... > The KB where the above code came from (with a slightly different order > of statement - need to unselect the old one before you assign the row > number) has a solution to also handle multiple selections. > > http://www.syncfusion.com/faq/windowsforms/search/856.aspx > > ====================== > Clay Burch > Syncfusion, Inc. >
Add custom button on title bar
Designing Email Msg. Bundle csv files Output Ascii 0x02 as part of record How to create generic object at run-time? Database Connection Speed Issue. I'm stumped! Versioning problem MsSql, MySql, Migrating from Access. Would like to see the Generated code in visual studio 2005 Check if string contain Uppercase. |
|||||||||||||||||||||||