DataGrid Multěple Rows Selection
Hello people, I would like to be able to select multiple rows in a datagrid as i click and drag the mouse over my datagrid just like excel. So far I can only select one at a time. Please advice and thank you in advance for your help
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Disabling The Selection Of Multiple Rows In MSHFlexgrid
I have a flex grid where my selectionmode is by column. But they are able to select(=highlight) multiple columns at once. I would like that if multiple columns are selected, that only the colsel is highlighted.
Is this possible??
How To Set Datagrid Support Multi-rows Data Selection
Except using the CTRL key, can I select multi-rows data by using row selector (on the most left-hand side along the datagrid) by moving my mouse along the row selector? Does datagrid support this? I think this is more convenient to user than holding the CTRL key.
Datagrid Multiple Selection -PLEASE HELP!!
I have a datagrid in VB.NET. I want the user to be able to select multiple rows and click a add button. I want to get the value of the ID column for each selected row. How can I do this?
Multiple Selection W DataGrid
I'm using a DataGrid with ADOX.
I'd like to do some operations on the user selected records (multiple selection)
Essentially, I want to get the list of .AbsolutePosition's of the records selected.
I have some opinion about SelChange, and SelBookmarks. SelChange is triggered as the selection changes. But I'm affraid, it gives no clue for differantiating the reason of the change, ie. whether it is an unselect, or an additional select, or a brand new row is selected.
SelBookmarks provides the collection of bookmarks, but I have no idea of how to go to the recordset.absoluteposition using bookmark of a row.
So... Could anybody help me please...?
Select Multiple Rows With Datagrid By Code
Is it possible to select multiple rows from a datagrid by code.
I have looked in the help and it suggests the propperty selStartRow and SelEndrow.
These do not seem to work.
Jet another bug from MS ????
Or is there another way to do this ?
DataGrid1.SelStartRow = 1
DataGrid1.SelEndRow = 3
DataGrid1.SelStartCol = 1
DataGrid1.SelEndCol = 4
Thanks 4 your help.
Selecting Multiple Rows In Datagrid Using The Mouse ?
Argh - cant find anything about this on the net.
So I try here:
I need to be able to make multiple selections in a Datagrid: click'n'dragging the mousepointer over the required rows - and using CTRL-selections too. Just like in Excel.
I dont want to use the MSflex or MSHflex-grids.
Is it possible ??
Any help appretiated
Shift-select Multiple Rows In Datagrid
I'm using a standard MSDataGrid (not Flexgrid) and I want to be able to click a row selector, hold down the <shift> key and select another row, and grab all the rows bwtween them. This is so I can quickly grab a set of values to mass edit or delete. Is there an easy way of doing this? I haven't been able to find much on a shift-select multiple records in a standard datagrid and need some help.
Selection Rows And Columns
When a block is selected in excel, how can we get the first and last row and the first and last column in the selected block?
Non_Continuous Rows Selection
Can somebody tell me are there any ways to select non_Continuous rows in a MSFlexGrid(By holding down the Ctr key)?
Hide Rows When Selection Change In Combo List
I have 2 options in my combo list. Eg. Apple and Orange
I would like to hide 5 rows (28:33) when Apple is selected and unhide those 5 rows (28:33) when Orange is selected.
When I assigned below macro to my combo list and select Apple, it will hide those rows but not able to unhide when I select Orange
If Range("B11").Value = "Apple" Then
Rows("28:33").EntireRow.Hidden = False
Rows("28:33").EntireRow.Hidden = True
Thank you in advance,
how do i restrict the number of coulumns that i can select in a datagrid
to just one row
that is at a particular attempt a user can select only one row
How Cam Add New Rows To A Datagrid
After populate my datagrid1 I want to add new records and it does not add new rows. It look like as static, I can write on the only row that show balnc but it does not display another row. I set the properties to True to add new rows, to delete, to update and nothing hapend. So my question is how can I do to make the grid open more rows. So the user not have opportunity to fill the columns.
Here is my procedure to feel the grid
strSQL = "Select * FROM ProjProd WHERE ProjectID =" & RecordID & ""
rsd.CursorLocation = adUseClient
rsd.Open strSQL, cn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rsd
Rows In Datagrid
Below is code to set up an ADODB recordset bound to a datagrid. I am unable to get the records to show up in the datagrid. Is there more code I need.
rMain(2).CursorType = adOpenStatic
rMain(2).LockType = adLockOptimistic
rMain(2).Open "SELECT * FROM Family" _
, cnn, , , adCmdText
DataGrid1.AllowAddNew = True
DataGrid1.AllowUpdate = True
DataGrid1.AllowDelete = True
DataGrid1.Enabled = True
Set DataGrid1.DataSource = rMain(2)
DataGrid1.Columns(0).DataField = "FirstName"
DataGrid1.Columns(0).Caption = "First Name"
DataGrid1.Columns(1).DataField = "LastNames"
DataGrid1.Columns(1).Caption = "Last Name"
DataGrid1.Columns(2).DataField = "FamilyName"
DataGrid1.Columns(2).Caption = "Family Name"
DataGrid1.Columns(3).DataField = "Spouse"
DataGrid1.Columns(3).Caption = "Spouse' Name"
Rows In Datagrid
i can search through columns in a datagrid
but i am having troubles searching through rows in a datagrid
my code for searching through columns in a data grid is as follows
Dim i As Integer i = 3 Do While i <> -1 txtWO = DataGrid1.Columns(i) MsgBox (txtWO) i = i - 1 Loop
if i change the above code to
Dim i As Integer i = 3 Do While i <> -1 txtWO = DataGrid1.Rows(i) MsgBox (txtWO) i = i - 1 Loop
it comes up with a compile error: Method or data member not found...
would anyone have a clue why it is doing this????
Datagrid And Rows
I have a datagrid and it is bind to a recordset. Now lets say I have 7 records in the recordset. So then my datagrid has 7 rows displayed for each record in my recordset. Now when I go and delete a record from my recordset, my datagrid will now display only 6 rows of records. The only problem is row number for each row does not change.
So lets say I have
Now I delete Row 5. My grid will be made up like this after the deletion.
Instead renumbering my rows to
This causes me a problem because i am using the event RowColChange which takes in a parameter LastRow and LastCol.
LastRow holds the row number of the row it was previously in and LastCol holds the col number of the col it was previously in. But if someone deleted a few records from my recordset, then when the event RowColChange gets called the LastRow value could be all messed up!! So in the example I gave on top if the user was in Row 7 and moved to a new row, when the event gets called LastRow will hold 7, but technically there is no Row 7, because the user deleted Row 5, which should make Row 6 now become Row 5, and Row 7 become Row 6!! Is there a way of fixing this?? I tried rebinding the datagrid to the recordset, but that did nothing besides screw up my format.
Datagrid # Of Rows
Three quick questions:
How can I programatically tell how many rows are in a datagrid?
How can I programatically tell how many rows are in an mdb table connected with ADO?
How do I programatically add rows to a table in an mdb connected with ADO?
Any help would be greatly appreciated!
Rows In Datagrid
I have a datagrid with a variable number of rows. I want to sum the coulmns, but I can't seem to find a way to move from one row to another in the datagrid or to determine even what row I am on.
Anbody have any ideas?
Selection Within Datagrid
I have to write my first VB Program, but some problems exists. I want copy a value, select range of fields within a datagrid, and parse value into those fields. The selected fields should be highlighted during selection (just like Excel). how can I do it? Please help!
Row Selection In DataGrid
I'm trying to generate an onClick event to select a full row of data in a datagrid when any cell is clicked on. To clarify: whatever cell is selected, highlight the whole row pertaining to that cell. Can anyone show me how to do this?
I am using a datagrid that is connected to an Access database via an ADODB connection. I would like to make mass updates dependent on the rows selected. I am going to create a few buttons that will populate a column with a set value. This will allow the tables to be locked from typing but I can still update them. So on to my question. Is there a way I can detect if a row is selected so I make the buttons available but not available when nothing is selected? I will then create the code that will update the values based on the button press.
Thanks in advance for any advice.
Can anyone there could help me of gettting the the Selected text in the the DataGrid through getting the DataGrid column and the DataGrid row. And also of getting the column name given the selected column and the row....
I hop there someone can help me coz i'm in trouble.....
I cannot procedd to my project and this is very important to me.
And Making are Right Click program that show the Pop-Up in the the DataGrid event.
Thnx in advance to you all....................GOd Bless
I am using a datagrid and want the user to be able to double click a row and a value in one of the cells (Decsription) of that row to be displayed in a textbox. I know how to do most of this, but i have one problem:
This is my code so far
Private Sub DataGrid1_DblClick()
Dim i As Integer
Dim cnnCLASH As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnnCLASH = New ADODB.Connection
Set rs = New ADODB.Recordset
cnnCLASH = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=N:Software Libarary ProjectAccessTablesTables.mdb;Persist Security Info=False"
intMsg = MsgBox(" are you sure you want to check out this item?", vbQuestion + vbYesNo, "CLASH")
If intMsg = vbYes Then
rs.Open "SELECT Description FROM tblSoftware WHERE Description = '" & DataGrid1
how do i actually reference the data in the required cell?
I know i have to declare a string variable to hold the data but how do i actually get the data?
thanx in advance
I am using datagrid. for me , i need a row to be
selected when i click on that (Colum must be assigned
to a variable from selected row ). For this what I
to do? please help me
I have datagrid that i populate from a databindingsource. The user enters a search criteria eg a surname and the datagrid is then populated with the matching Surnames and also other information.
However from the list i want the user to be then able to double click on a row, in the datagrid results, then the user is taken to new window. where more information concerning the customer is shown. Therefore, on slection i want the customer ID (from the datagrid selection) to be somehow passed in to a query for the query to the return the required results dor the slection. Or if any experts have any other suggestions these would be greatly appreciated.
Thanks in advance
Row Selection In Datagrid
Here's the situation:
I've assigned a recordset to the datagrid. It worked fine. I can also select the desired row through selbookmarks. Now, there are 13 columns so I have to scroll to the right to see the other columns. But when I do that, the background of the selected row changes from black to white. When I scroll it back, the background changes from white to black. What I want is to keep the background in black even when I scroll. I've tried selbookmarks but it didn't work. I also searched for the selstartrow property but it seems it is not supported (I'm using Visual Studio 6 SP6). Do you have any solutions to this problem?
Multiple Row Selection
I was trying to select multiple rows from a MSHflexgrid and would like to assign the selected rows in an array or a variable....
How do I capture all the selected rows from a grid???
Also, I have one more question..I would like to use tab space and new line characters like
an d ...I have seen vbtab and vbNewLine ..but not know the correct usage..I am new to VB and don't have much references...Pls help me..
Hello i have about 12 command buttons
One at the top the other. I also have another group of command buttos (15 of them) on at the top of the other,all are control arrays
I want to change the font properties of these buttons.
anyone know how to change one group to one font type and the other ot another type of font.
i tried lasso select but did not work. i also do not want to do it one at a time becuse the order matters and it is time consuming
any idea is appreciated.
I am developing an application that need to read data from different
.txt files. My problem is how do I configure my CommonDialog box to
allow multiple selections? And how do I list all the files on the list
John J Mabasa
084 824 5079
011 688 6534
I have a ListBox and as default i can just select to delete only one item at a time. How can i make multiple selection by mouse and ? Thanks in advance for you help
Multiple Name Selection In VB
I have a simple question about VB coding for an access application...I had it working with one user but cant get it with multiple users...I want to be able to check a table and if the users name is in this table I want to unlock a button on the application..here is the code that works with one user...
Private Sub Form_Load()
If UserNem = "Tim" Then
[Command12].Enabled = True
[Command12].Enabled = False
Copy Rows In Datagrid
How can I get to copy rows in datagrid with Ctrl-C for example to transfer these information to clipboard?
Exists an easy solution for it?
Editable Datagrid That I Can Add Rows To
I was looking at what seems my 2 only options: MS Datagrid (which lets you edit cells, but not add rows) and MS Flex Grid, which lets you add rows but not edit cells)
I need a grid that will let me add rows to it, as well as edit cells in the grid. I could do that trick with the flex grid putting a text box on top of the cell, but I was hoping there was a keener way.
Blank Rows In A DataGrid
I have built a DateGrid and here is what's going on. When the form opens up, the DataGrid will populate with the correct number of rows so if I had 35 rows in my recordset, there would be 35 rows in the DataGrid. Here's the problem. The rows created are blank. I will post my code in a minute. I have checked to make sure all of the form and DataGrid properties are set correctly and I have debugged the software and the recordset, when ran, does hold the correct information but the rows are blank. Here's the kicker. I wrote a snippet that would move the recordset to the 6th row and when I ran the program, it would take the value of the 6th row and place it in a text box. That worked perfectly and the DataGrid even showed the arrow beside the 6th row. I'm stumped. Can anyone see any errors in my code or have any clue why this is happening? Thanks, Jeremy
Private Sub Form_Load()
'Declare Connection Variables
Dim OraCon As New ADODB.Connection
Dim OraRec As New ADODB.Recordset
Dim SQLQuery As String
'Create Connection Object
Set OraCon = CreateObject("ADODB.Connection")
OraCon.ConnectionString = "Provider=OraOLEDB.Oracle;" & _
"Data Source=MYDB;" & _
"User ID=*****;" & _
OraRec.CursorLocation = adUseClient
SQLQuery = "SELECT IM_KEY,IM_DESCR FROM IM ORDER BY IM_KEY"
OraRec.Open SQLQuery, OraCon, adOpenKeyset, adLockOptimistic, adCmdText
If OraRec.RecordCount = 0 Then
MsgBox "No record found!"
Set DataGrid1.DataSource = OraRec
Transfer Rows From One Datagrid To Another
I would like to know what I am missing. I have imported an excel sheet into a datagrid and have added checkboxes. I have also set the checkboxes to be true on default. I need to know how to be able to transfer those ticked rows to another datagrid. This is to be done by clicking on another button. It needs to look at how many and which rows have been left ticked and then transferred over to another datagrid.
The users will only be touching the checkboxes if they need to unselect them.
Here is my code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Create an OpenFileDialog in order to browse for an Excel file.
Dim fileDialog As New OpenFileDialog
'Use a DialogResult to determine whether the user selected a file or cancelled.
Dim dialogResult As DialogResult
'Setup the OpenFileDialog
.Title = "Select Excel File"
.Filter = "Excel (*.All files)|*.*"
.CheckFileExists = True
dialogResult = .ShowDialog
If dialogResult = dialogResult.OK Then
'Call the ShowExcelFile routine as we have a file.
Public Sub ShowExcelFile(ByVal excelFile As String)
'Using ADO.NET, populate a DataTable with the contents of the first sheet of an Excel file.
'more logic will be required if you need to display a certain work sheet.
Dim connection As OleDbConnection
Dim adapter As OleDbDataAdapter
Dim excelData As DataTable
'Instantiate the connection object using a connection string suitable for Excel
connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & excelFile & ";" _
& "Extended Properties=Excel 8.0")
'Prepare the OleDbDataAdapter to select data from the first worksheet.
'NB: This assumes that the first worksheet is called Sheet1.
adapter = New OleDbDataAdapter("SELECT * FROM [Sheet1$]", connection)
'Instantiate the excelData DataTable and populate it by using the Fill method of
Dim dc As DataColumn
Dim dr As DataRow
excelData = New DataTable("ExcelData")
Dim ds As DataSet
ds = New DataSet("ExcelData")
dc = excelData.Columns.Add("Yes", System.Type.GetType("System.Boolean"))
excelData.Columns.Item("Yes").DefaultValue = True
dr = excelData.NewRow
DataGrid1.DataSource = ds
'Clear any bindings from the DataGrid and set the DataSource of the DataGrid
'to the new excelData DataTable
DataGrid1.DataSource = excelData
Catch ex As OleDbException
Catch ex As InvalidOperationException
Catch ex As Exception
'Tidy up used objects
If Not connection Is Nothing Then connection.Dispose()
If Not adapter Is Nothing Then adapter.Dispose()
If Not excelData Is Nothing Then excelData.Dispose()
'This is to get the checkbox to react to the first click
Private myCheckBoxCol As Integer = 0 'my checkbox column
Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles DataGrid1.MouseUp
Dim hti As DataGrid.HitTestInfo = Me.DataGrid1.HitTest(e.X, e.Y)
If hti.Type = DataGrid.HitTestType.Cell AndAlso hti.Column = myCheckBoxCol Then
Me.DataGrid1(hti.Row, hti.Column) = Not CBool(Me.DataGrid1(hti.Row, hti.Column))
Catch ex As Exception
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
' I need something to go here to retrieve the ticked rows.
Can somebody please help? I'm new to VB and i'm using Visual Studio 2003.
Counting Rows In A Datagrid
im revisiting an issue i havent been able to resolve. How would i go about counting the total number of rows that are pulled within the datagrid. the datagrid1.row for some reason only counts the rows that are visible on the screen. however i would like to have a total count of all rows. how could i go about this. thanks
Color For Rows In DataGrid
I have a datagrid Control, and i want some rows in accordance with some criterial has a diferent color. For example, the rows with data USA, rows color blue. Rows with data EUROPE rows color red... etc
how can i do ??
Locking Rows In A Datagrid
what i need is lock some rows in a datagrid.
the problem is there is no lock property for rows in a datagrid so i tried to lock the whole datagrid (each column) depending on a value in one of the datagrid columns (this column contains the criterium if the row is editable or not)
the problem is what is the right event i should hang the check if the row is editable or not onto?
i tried it with rowcolchange but that didn't work as well as click and double click.
when i used click the row which was checked was the row in which the bookmark was before the click event and when i used dblclick the problem was that when i left the current (editable) row the whole datagrid stayed editable because i didn't dblclick it.
here is the code :
Dim i As Integer
dgr.Col = 7
If CInt(dgr.Text) = 1 Then
For i = 1 To 7
dgr.Columns(i).Locked = False
For i = 1 To 7
dgr.Columns(i).Locked = True
or is there any other possibility i didn't think of?
Multiselect Datagrid Rows
Hi, is there a way (or code) to which I can have a multiselection in the db grid (dbgrid32.ocx) like when I press shift key or ctrl key then click the rows I want to select?
Delete Rows From A Datagrid
I want to delete records from the datagrid
here's what my datagrid look like, just a sample..ok
I only want to delete rows which has 'f' on it
here's my code so far...
For i = 0 To dbgChks.ApproxCount - 1
If dbgChks.Columns(5).Value = "f" Then
I don't know what to write between the if statement, for I haven't
use a dbgrid in removing records, I'm trying to edit a program
and the dbgrid was the object used
dbgchks is the name of the dbgrid
please help, thanks in advance
Selecting Rows In A DataGrid
I'm using a datagrid (dgSrchRes) that is populated programatically froma recordset (rsSrchRes). After data is diplayed in the datagrid the usershould be able to locate a record by entering a value into an unboundtext box (sglFreq) and clicking a command button. I'm using thefollowing code for locating the desired row but it is not working:
rsSrchRes.Find "Frequency = " & sglFreq
If rsSrchRes.EOF Then
MsgBox "Specified Frequency not found", vbOKOnly, "Note"
Please if anybody have an answer to this, I'll be very thankfull.
Scroll Thru DataGrid Rows
I am trying to read through each row in the datagrid. However, I am staying on the row that is currently highlighted in the grid. ????
Here is the code I have. The actual column in the grid is an expiry date. So, I am checking to see if any or all of the rows have an expiry date... I they all do then I need to display a message BUT if even one of the rows does not have an expiry date(meaning they are still active) then I will not need the message displayed.
Thanks in advance for any help you are able to provide.
Dim i As Integer
Dim count As Integer
For i = 1 To grdBeneficiaries.ApproxCount
If (g_AppUtil.GetGridColumnValue(grdBeneficiaries, 4)) <> "" Then
count = count + 1
If count = grdBeneficiaries.ApproxCount Then
MsgBox CONST_MSG_CLOSE, vbExclamation
Cancel = True
Datagrid Rows Question
I am using a datagrid to navigate through a recordset contained in an ADODC Recordset.
How can I tell which row I've clicked in in the datagrid so I can navigate through the recordset to that record? The area I am having a problem is when the datagrid scrolls so that the displayed records are completly different than originally displayed, so the datagrid.row property doesn't apply. It seems limited to the displayed set of rows.
Removing Rows From Datagrid Help
I have a datagrid that is bound to a recordset as its datasource. Part of the applications operation is the user can select a single item or multiple items in the grid and click a button to remove them. To do this I iterate through the .SelBookmarks and remove the rows by deleting them from the recordset and then the RS gets updated.
The proble is, if the user removes am item, then removes a second one all goes crazy when setting the grid row to a selected row! Basically after removing the first row the first time and then removing the second row after the selected row may be 0 but the first selected bookmark in SelBoolmarks is 2
Is there some way around this?
Processing All The Rows Of A DataGrid
I've noticed from a few posts that people have been wondering how to process all of the rows of a DataGrid, since it is not apparent in the available Properties/Methods.
I for one, have been frustrated by the fact that .Row only applies to .VisibleRows which sucks. I have written the following code for going through all of the rows of a DataGrid. I hope it helps some people. If there has already been code posted doing just that, then great. If not, then great. So it doesn't matter really. Have fun!
Dim MajorCounter As Integer
Dim counter As Integer
'MajorCounter allows you to go through all of the
'rows of the DataGrid. Adodc1 is the Data Source for
MajorCounter = Adodc1.Recordset.RecordCount
'Start from the last Row up to the first
.Scroll 0, MajorCounter
'Handle all of the visible Rows before .Scroll
counter = .VisibleRows
Do While MajorCounter > 0
'Do the visible Rows first
If counter > 0 Then
.Row = counter - 1
counter = counter - 1
'The visible Rows are handled, now for
'the rest going up to the first Row
.Scroll 0, -1
'Each Row that appears at the top because
'of .Scroll should be the current Row
.Row = 0
'Do whatever you want to do here for each .Row
MajorCounter = MajorCounter - 1