473,657 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid Multiple Select

I have a VB.NET 2003 application that uses several datagrids. The behaviour
I 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 DataGridTextBox Column and overrides the
its Edit method. i.e.

Public Class DataGridNoActiv eCellColumn
Inherits DataGridTexBoxC olumn

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.Cou nt) then
Me.DataGridTabl eStyle.DataGrid .Unselect(Selec tedRow)
Me.DataGridTabl eStyle.DataGrid .Select(Selecte dRow)
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.DataGridTabl eStyle.DataGrid .Unselect(Selec tedRow) line, and created my
DataGridTableSt yle 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

May 3 '07 #1
2 6788
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/window...earch/856.aspx

=============== =======
Clay Burch
Syncfusion, Inc.

May 3 '07 #2
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 DataGridMultipl eSelectColumn that
inherits from DataGridTextBox Column, 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.D atagrid and added a boolean property AllowMultipleSe lection.
I then override the OnMouseDown Event as follows:
Protected Overloads Overrides Sub OnMouseDown(ByV al e as MouseEventArgs)
Dim aHitTestInfo as DataGrid.HitTes tInfo
aHitTestInfo = Me.HitTest(New Point (e.X, e.Y))
If (aHitTestInfo.T ype = Me.HitTestType. Cell and
AllowMultipleSe lection) then
MyBase.OnRowHea derClick(e)
End if
End Sub
However, this doesn't select the row. Is it because OnMouseDown takes an
argument of type MouseEventArgs and OnRowHeaderClic k takes an argument of
EventArgs, and if so how do I convert between them? Thanks for your help.

Andy Baker

"ClayB" <cl***@syncfusi on.comwrote in message
news:11******** **************@ h2g2000hsg.goog legroups.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/window...earch/856.aspx

=============== =======
Clay Burch
Syncfusion, Inc.

May 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7680
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official Impact Summary</td> </tr> <tr> <td colspan=2></td>
1
2589
by: Soul | last post by:
*** I am not sure this question belong to *.languages.csharp or *.framework.windowsdorms.databinding, so I post to both *** Hi, Currently I have a DataGrid which bind to a DataSet. One of the column in the DataSet table consist of DateTime value. I also have two DateTimePicker (startDate and endDate) on my Windows form.
2
9920
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell (multi-select without modifier keys). I got that working fine, but I also wanted to keep rows selected after a sort, which I do by storing the row's id in an arraylist. The idea was to do the sort and then go back and re-select the rows with that...
5
3525
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all selected items of that listbox and display it. can anyone help? Thanks
1
3343
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been able to find any examples which demonstrate how to do this. My Code:
13
2472
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for them. In a plain vanilla DataGrid, when you click on the RowHeader, the appropriate row changes colors. I ASSUME this should be done in the Paint (or PaintText) override of the DataGridColumnStyle in question. My problem is that I don't know...
5
6546
by: Vik | last post by:
If there are a few Select buttons in a datagrid, is there a way to distinguish in code which button was clicked? Thanks.
0
1334
by: rn5a | last post by:
A DataGrid control displays records from a SQL Server 2005 DB table. The AllowSorting property of the DataGrid has been set to True & the SortExpressions of the BoundColumns have been set to the different columns so that users can sort the DataGrid by clicking the headers in the DataGrid. The DataGrid can be sorted using all the headers in the DataGrid except for the first column header. <asp:DataGrid ID="dg1" AllowSorting="true"...
2
1661
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all Got a weird problem with pagination on a datagrid in asp.net 1.1. It's populated depending on user selected criteria (it either displays all or 1 record). It works fine in the following circumstances: Datagrid populated with 1 record then re-populated with all Datagrid populated with 1 record then re-populated with another single record Datagrid populated with multiple records and displaying page 1 then
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.