Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Selected Row In Datagrid


I want to write a code in rowHeader(ie.. when clicking on a particular row ) event of datagrid in vb.net.
how to raise this event in vb.net




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Which Row Is Selected In DataGrid...
How can you tell which row is selected in a datagrid?
It would be good if this row had a number like in an index or something...


Also,
How can I use a datagrid to edit the information in my recordsource? I have AllowUpdate set to true, but I just don't see any update method for the control...

thanks so much,
squirrelly1

Datagrid Selected
I have 2 datagrid in a form and i want to know which datagrid is selected when i click a command button it will identify which datagrid is selected.

Thanks.

Datagrid Row To Be Selected
Hi,

I'm currently using data environment in populating my datagrid.

Each row contains ID, Name, Class and Description columns

I have a textbox which i enter the ID to search.

How can the particular row in the datagrid being highlighted once i enter the ID into the textbox?

Thanks


Roy

Detecting IF A Row Is Selected In A Datagrid?
Using VB 6.0, is there any way to determine if a row has been selected? If the user does not select a row (or hasn't as of yet), the arrow on the right side is, by default, at the first row in the datagrid.

What I'd like to do is make that NOT the default. So, if a user accidentally hits a command button (like to delete the selected row), it won't happen unless the user has actually selected a row.

How would I go about doing this?

Thanks in advance for any help.

DTFan

Delete The Selected Row From A DataGrid
How can I remove the selected row from a DataGrid control without removing from the asociated recordset.

Regards,
fazek

Selected Field On Datagrid
Well the below code will populate all the fields after a search from SQL statement.

I want SELECTED fields to be display instead of all the fields.For example in the table i have 20 fields but i want to display 5 fields in datagrid1. How does the code look like?


VB Code:
oRs.Open SQL, oConn, adOpenStatic, adLockPessimistic, adAsyncFetchSet DataGrid1.DataSource = oRs


2nd question.
Once the record displayed in datagrid1.
Highlight the record
There is a button where i can click on the higlighted record.
All 10 fields will display in form2
and another 10 field display form1

How to do that?

Selected Position On DataGrid
Hi all

Now I am trying to get selected position where user clicks on DataGrid.
My test code is as follows.

Private Sub dgTrouble_Click()

    Debug.Print "Row :", CStr(dgTrouble.Row)
    Debug.Print "Col :", CStr(dgTrouble.Col)
    
End Sub

When I clicked certain cell on DataGrid for the first time,
I got a position data .
Then I clicked same cell , I got different position data.
But after this click, I got same position data at this cell.

I want to get same position data at first click.

Please give me some advices for resolving above problem.

 






Get A Field Value From Selected Datagrid Row
Hi

I've not coded in VB6 for quite some time am having  trouble and could use some help. I'll keep this short.

I have a datagrid populated with a recordset. If a user clicked somewhere on row 5 how could I get the value of say field 3 from row 5?

I would appreciate any help that anyone could lend.

Thanks

Hot To Delete Selected Row I Datagrid?
please help give me simple code

Datagrid Selected Row Plz Heeeeelp :(((
I use VB 6.0 and MS access

how can i get the selected row number in datagrid
and how can i set the selected row (ex. datagrid.selected row=5 )

Best regards....

How Can I Show The Selected Row In Datagrid
hello
i want to show current row which is the result of my query in datagrid
how can i do ?
In MSDN it is written "The data in the current row can be accessed using the Bookmark property"
ok it works but i want to set datagrid like datagrid1.bookmark =i but it doesn't work
also datagrid1.row is not the property that i want to use .

Detecting Which Row (DataGrid) Was Selected
Hallo,

How can I (programatically) detect which one row (DataGrid) was selected?
Can I do any action after doubleclick on DataGrid?
I would like to take selected row and read its values.

Thanks for help.

Keep Selected Row Hig-lightened When Sorting Datagrid
I have a data grid with multiple columns. The user can sort the grid based on the column. When the grid is sorted the row that the user had selected is not "high-lightened" and the pointer arrow in the first column moves to the first record. Can any one plz help me keep the selected row highlightened even after the grid is sorted. This should be like the windows explore. I am using ADO to connect the MS access database

Datagrid Selected Item To Text Box...
Dear Friends,

How can I get the data into a text box (eg. Text1.Text) which is selected in a Datagrid1.

Seema_S

Datagrid (copy Selected Text)
How do I copy text from a datagrid? Let's say I highlight 3 rows, how do I copy the text that was in the selected rows? Thanks.

Getting Text Of Each Item Selected In DataGrid
Hi everyone .... I need to get the text of each item selected in a multi-select DataGrid control. I can get the index number, but so far, each attempt I have made only gets me the first item selected. I need the text of each item selected to build a SQL statement.

Passing Selected Row In Datagrid To An Array
Hi all,

Currently I'm working on a program that retrieves addresses from anoracle
DB and stores these in a local access database.
I'm able to retrieve records from the oracle database and put them intothe
datagrid, but now I'm stuck.
When I select a row, how can I put those records in an array, or even
better, directly into my local access database?

I googled and altavista'd but I couldnt quite get an answer. MSDN isntvery
clear about this either.

If anyone can help, I'd be delighted.

TIA,

Robin



Gemeente Veendam


Bezoekadres:


Raadhuisplein 5


9641 AW Veendam



Postbus 20004


9640 PA Veendam


Telefoon: 0598-652222


Fax: 0598-652250



De informatie in deze e-mail is vertrouwelijk en uitsluitend bestemdvoor de
geadresseerde. Indien de lezer van deze mededeling niet degeadresseerde is,
wordt u er hierbij op gewezen, dat u geen recht hebt kennis te nemenvan de
rest van deze e-mail, het kopi=EBren of te verstrekken aan anderepersonen dan
de geadresseerde. Indien u deze e-mail abusievelijk hebt ontvangen,brengt u
dan de afzender op de hoogte waarbij u gevraagd zal worden hetoriginele
bericht te vernietigen. De Gemeente Veendam is niet verantwoordelijk en
wijst iedere aansprakelijkheid af voor en/of in verband met allegevolgen
en/of schade van een juiste en volledige verzending en ontvangst van de
inhoud van deze e-mail.

The information in this e-mail is confidential and intended solely forthe
person to whom it is addressed. If this message is not addressed toyou,
please be aware that you have no authorization to read the rest of this
e-mail, to copy it or to furnish it to any person other than theaddressee.
Should you have received this e-mail by mistake, please bring this tothe
attention of the sender, after which you are kindly requested todestroy the
original message. The Gemeente Veendam cannot be held responsible orliable
in any way whatsoever for and/or in connection with any consequensesand/or
damage resulting from the proper and complete dispatch and receipt ofthe
content of this e-mail.

DataGrid And Delete Selected Record
I have DataGrid1 connected to dbf file and i wanna delete selected record in in dbf file how to make this ?

GRRR DataGrid Selected Cell
"GRRR" mostly because my problem seems like its an absurdly simple one, that a million people have prolly aksed before... yet I am unable to find a solution for it anywhere I look, including VbCity.com... maybe im not looking hard enough, maybe im just a retard... either way i need to know how to solve my problem:

I have a DataGrid populated with a RecordSet, and a DataGrid onclick event...
I need to pull the value of a clicked cell out and do stuff with it... (pass it to another function for example)...

This is the function Im using to suss things out at the moment

Code:Private Sub dgdAllOrders_Click()
    
    With dgdDataGrid
        dgdDataGrid.Refresh
        Debug.Print .Text
    End With

End Sub

Problem is that the click event is Debug.Print-ing the value of the cell clicked before the cell just clicked... I need it to return the value of the cell just clicked, not the cell I clicked before that...

Prolly uber-simple, i know... but im pretty stumped...

Chur




Edited by - SnaxNZ on 10/9/2003 6:16:52 PM

Help! Please Tell Me How To Get The Index Number Of The Selected Row In Datagrid?
For example I have a datagrid that has contents on it,I want to get the indexed nuumber of the selected Row,if i select the 3rd row I would get the index 2 because it start with 0.

Hope someone understands my question and hope someone could help me.

Thanks in advance!!!

How To Print Selected Rows From Datagrid.
Hi friedns

I have one datagrid having colums ItemNo and ItemName. I want to print those ItemName which ItemNo my clinet choose from datagrid..

hOw can i do this???



pratik mehta

Deleted Selected Records In Datagrid In Vb6
I have a number of records in datagrid1 in vb6, i want to delete selected records from datagrid. suppose user selects row no. 1, 4, 10, 15 and when he clicks delete button which is there in form, the selected row (records) should be deleted.

Please help me to do this in vb6. i will wait on nitin@alsahel1.com

Thanks & regards,

Nitin

I Can't Display What Is Selected In The Datagrid, To Textboxes.
Hi,
I select a row in the datagrid, but only the first record in the recordset is displayed.It only displays if I double click on the record.IT should happen only with a single click.

Here is my code...
Code:
    Private Sub DataGridUser_click()
   
       SelectedUser = DataGridUser.Columns(0).Text
    
       Init_PopulateUser
    
    End Sub

Private Sub Init_PopulateUser()

    Do While (adoUsers.Recordset.Fields("UserID") <> SelectedUser)
        adoUsers.Recordset.MoveNext
    Loop
    
    txtID.Text = adoUsers.Recordset.Fields("UserID")

End Sub

Thanx, your help will be greatly appreciated
David

       David Noel Augustine

Come to Port Elizabeth, South Africa
        "The Friendly City"
   "white sands, blue ocean..."

How To Display Selected Columns In DataGrid
I tried searching in this forum for a solution to my problem and I didn't have any much luck. Can someone please help me in my program?

I have a table called Transaction_Detail, it has several fields but I do not wish to display all of them. I do not wish to display the SSN but I will need it later on when they update the record in the DataGrid.

Is there a way to do this?
Below is a a snipet of my code.


Private Sub cmdDisplayRecord_Click()

Set rsTransaction_Detail = New ADODB.Recordset
mysql = "SELECT SSN,Tran_ID, Tran_Seq_ID as [Seq No], Tran_Date as [Tran Date], Beg_Balance_Amt as [Beginning Balance] FROM Transaction_Detail WHERE SSN = " & CDbl(txtSSN.Text)
rsTransaction_Detail.CursorLocation = adUseClient
rsTransaction_Detail.CursorType = adOpenDynamic
rsTransaction_Detail.LockType = adLockOptimistic
rsTransaction_Detail.Open mysql, adoBenConn



Set Adodc1.Recordset = rsTransaction_Detail
Label1.Caption = Adodc1.Recordset.Fields.Count
Set rsTransaction_Detail.ActiveConnection = Nothing

Call pInitializeGrid

'Label1.Caption = CStr(rsTransaction_Detail.RecordCount)

End Sub



Thanks

Datagrid: Change Color Of Selected Row
Hi vbPals !!!

I have a datagrid and when I select a row, it shows the default black color (which has nothing to do with the graphical user interface of my application...)

How could I change it ? (I accept "advanced" answers )

Help Datagrid Text Selected Problem
I am tried to get in on grid_click event the current cell value select by the end user by bookmark and as well by seltext,cellvalue,celltext.
the seltext return the select text before and not the current.
with grid.columns(col).cellvalue/celltext(grid.bookmark)
return only text from the second row
if i cliked on the firs row it cuase to error like invalid row or somthing like that
can anyone tell me wats wrong
thanks and god bless you

How Do I Determine The Selected Rows In A Datagrid?
Hello

I am using a datagrid bound to an adodc data control in a Visual Basic 6 application. With the control key i can select multiple rows. How can i programmatically determine the selected rows in the datagrid?

With the method datagrid.IsSelected(i) it should be possible in a VB.net environement but how do i do it with VB6.

Thanks in advance

Duck

How Do I Track Which Record Is Currently Selected In A Datagrid
Hello,
i want to give the user a method of editing a record which he selects from the datagrid.Problem is how do I check which record the user has selected.
I have used a round-way method by calling the buttonClick method
Is there a better way.
Thanks in advance...

Sort On A Selected Column In A Datagrid
Hello, I'm using a datagrid to display an access database table. Everything is working fine.

What I would like to do is sort the datagrid based on a user selected column.

What is the best way to do this? Is the best way to re-query the database? And if so, how do I display the new results into the datagrid. Ive figured out that I can determine what column the user selects by 'DataGrid1.SelStartCol'.

Thanks for any suggestions.

Bob

Datagrid - Refer To Data In Selected / Highlighted Row
I have a datagrid which on my VB6 form. This links to a table in a database and displays the records there.
I want the user to select a row (or rows) on the datagrid, click my command button and then these selected records to be moved to another table in the database.
I know how to write records to a database table.

What I want to know is how to refer to the data in the selected row?

Thank You

Loading Datagrid With No Default Record Selected?
I've got a datagrid that is loaded when the form loads. It's get it's data from a database table and is populated with the primary key in descending order (latest entries appearing first). This all works fine (no errors). But I would like to change one thing. When the form loads, there is automatically an arrow in the gray box next to the first row in the datagrid. That record is pre-selected (I assume that what it is doing). Anyway, I would like to load the datagrid but not have that first record selected.

Is this possible and, if so, how would I go about doing it?

Thanks in advance for any help you can give.

DTFan

Display Currently Selected Record Of A Datagrid In Textboxes?
I have a datagrid control on the form.
What I want to do is the moment user clicks on the rowheader(the little gray button in front of each roa), I want
to display the corresponding records values in text boxes.
Can anyone please help me how to do it?
I have been trying since long, but no luck.
Thanks in advance
Regards
Kalpana

Placing Selected Line From DataGrid Into Textbox
All,
I am trying to place selected text from a datagrid into multiple textboxes. I can get data from first row of the datagrid without any problems, but I want to get the row that is selected. Any help would be appreciated.

J.

Selected Text From List Box Adding To DataGrid?
Hi there...
Can anyone help me to sort this out..

Recordset populate the Listbox through query. DataGrid is bound to a table. I want to add selected Text from List Box to DataGrid .. please help.

Populate DataGrid Based On A Selected Combo Box Value
Hi,

How do I populate results on a datagrid based on the user I select from a combo box. I have a combo box with X number of users and want to show the results for a user A only.
I am filtering the results for each user based on option buttoms whether the job is finished, live, or all.
Right now I can display the results for all users regardless which one I select in the combo box.
This is really driving me crazy now, please help.
I have no much experience in this, so I will be gratefull.
Below is the code I am using for this.

Thanks

dfuas


Code:
CREATE PROCEDURE SP_CREQUEST_SEARCH
AS


SELECT R.RequestID, R.ShortDescription, RTRIM(U.FirstName) + ' ' +RTRIM(ISNULL(U.LastName, '')) AS 'User Name',
D.Department, R.StartDate, R.EstimateDate, R.FinishDate, R.LastUpdate

FROM Request R INNER JOIN
Users U ON R.UserID = U.UserID INNER JOIN
Department D ON U.DepartmentID = D.DepartmentID



VB Code:
Private Sub cmdSearch_Click()    Dim cmd As ADODB.Command    Dim rst As ADODB.Recordset    Dim Temp$            Set cmd = New ADODB.Command    Set rst = New ADODB.Recordset                OpenConn        With cmd        .ActiveConnection = cn        .CommandType = adCmdStoredProc        .CommandText = "VIEW_USERS_SORTED"                End With        CloseConn                If Me.cboSearchFor.Text <> "" Then                If Me.optSearchFor(0).Value = True And Me.optSearchCriteria(0).Value = True Then                                Temp$ = Me.cboSearchFor.Text                With rst              rst.Filter = Temp$            End With            Set rst = Nothing     Call GetSearch                  End If                    End If             End Sub



VB Code:
Private Function GetSearch(Optional UserId As Integer)     Dim cmd As ADODB.Command    Dim rst As ADODB.Recordset     Set cmd = New ADODB.Command    Set rst = New ADODB.Recordset        OpenConn        With cmd        .ActiveConnection = cn        .CommandType = adCmdStoredProc        .CommandText = "SP_CREQUEST_SEARCH"                        Set rst.DataSource = .Execute                Set Me.grdSearch.DataSource = Nothing        Set Me.grdSearch.DataSource = rst                If Me.optSearchCriteria(0).Value = True And Me.optSearchFor(0).Value = True Then                        rst.Filter = ""            rst.Filter = "FinishDate <=" & Date                ElseIf Me.optSearchCriteria(1).Value And Me.optSearchFor(0).Value = True Then                    rst.Filter = ""            'rst.Filter = ("FinishDate >=" & Date Or "EstimateDate >=" & Date & "'")            rst.Filter = "EstimateDate >=" & Date            rst.Filter = "FinishDate = NULL"            rst.Filter = "EstimateDate = NULL"                    ElseIf Me.optSearchCriteria(2).Value And Me.optSearchFor(0).Value = True Then                        rst.Filter = ""            rst.Filter = adFilterNone                    End If                         End With        CloseConn End Function

Inserting Data In Datagrid After All Rows Selected
This code works fine for selecting all the rows in a datagrid. I'm needing a way to insert data into 2 columns in each row in the datagrid
==========================
Private varBookmark As Variant


Private Sub Command1_Click()
Dim rs As ADODB.Recordset
Set rs = Adodc1.Recordset.Clone
Rs.MoveFirst
Do While Not Rs.EOF
varBookmark = Rs.Bookmark
DataGrid1_SelChange (0)
Rs.MoveNext
Loop
End Sub


Private Sub DataGrid1_SelChange(Cancel As Integer)
DataGrid1.SelBookmarks.Add varBookmark
End Sub
====================
Now for my question that will finally get me up and running as to what the boss wants to do. I need to add the following
to the code so that this is inserted into each row. So far when I have tried to add this to the code it only does it for the first row in the datagrid. Can anyone help as to how I can insert this into each row in the datagrid ??

DataGrid1.Columns(4).Text = "1"
DataGrid1.Columns(5).Text = Date

Thanks for any and all help

How To Fill Datagrid With Selected Access Table
Hi All,
I'm new to VB.Net and I have a problem accessing selected data in an access db. I keep getting the whole table entries in the datagrid, instead of the results of me SQL select.
Can anybody help me.

Thanks
George

Bookmarking A Selected Record On A Datagrid From A Combo Box
I have a datagrid listing some part information from a database.  I have a combo box which lists part numbers.  I want to be able to select a part number from the combo and be able to set the bookmark of the datagrid to the matching record.

This must be simple as it's a basic search/find function but I must be looking in the wrong place as MSDN and the rest of the net doesn't seem to give me an answer!

Thanks
Andrew

VB6 Datagrid Question - Number Of Selected Rows?
How can I programmatically determine the number of selected rows in a bound
Datagrid? Thanks.

Display Selected Row Details From Datagrid To A Textbox
Hi, can anyone help me with the above question?

How To Copy Selected Records From DataGrid To Clipboard
1. How to on multiselection records in datagrid? because when i click on first record and then on second two record then first record lost selection
2. How to copy only selected records from datagrid to clipboard?

i write something like this

Private Sub DataGrid2_Click()
Dim abc As String

abc = ""

Do While Not rer.EOF
        abc = abc & " " & rer.Fields("FE") & " " & rer.Fields("TYP") & " " & rer.Fields("ZIARNO")
rer.MoveNext

Loop


Clipboard.Clear
Clipboard.SetText (abc)

End Sub

and this working but how to select more than 1 record? I use CTRL and select multi records but then this program not working

Updating Datagrid When Record Selected In Bound Combo
I have a bound datacombo box which displays drawing no's. When a drawing no is selected, several text boxes are updated to reflect that record. This part works fine.

I then query the text box to update the ado controller on the datagrid. This doesn't work fine.

I need the datagrid to update and reflect associated member records. For every drawing no there is many members records.

Here is the code I am using. The first part is fine. The problem is with the update of dcboMemReg. Any help would be great.


Private Sub dcboDrawingNo_Change()

'Update Drawing text box ado controller when drawing no changes

Dim strQuery As String

strQuery = _
"SELECT * " & _
"FROM [Drawing Register] " & _
"WHERE fldDrawingNo = '" & dcboDrawingNo.BoundText & "'"

With adoDrawingText
.RecordSource = strQuery
.Refresh
End With


'Update the member register data grid when drawing no changes
' strQuery = ""
strQuery = _
"SELECT * " & _
"FROM [Member Register] " & _
"WHERE fldDrawingRegisterID = " & txtDrawingRegisterID.Text

With adoMemReg
.RecordSource = strQuery
.Refresh

End With

End Sub

Datagrid Click Not Passing The Selected Data To Textbox
it bothers me why after clicking the datagrid and a selected data was highlighten the recordset still passing the previous data.

I use to pass the data to a textbox after clicking one of the records shown in a datagrid. but it happends to have a late reaction. when i choose the 2nd record the 1st one will be displayed in the textbox. then try another record then it will just display the previous one which is the 2nd record and do another then same thing will happened.

i check using debug.print the recordset and same output will appear.

what's wrong with it? im using ado and i just use this to connect with the source "Set datagrid.source = rs"

and this is the code when i click datagrid to select a data...

VB Code:
Private Sub DataGrid1_Click() DataGrid1.SetFocusDataGrid1.MarqueeStyle = dbgHighlightRow Text1.Text = DataGrid1.Columns(0)Text2.Text = DataGrid1.Columns(1)DataGrid1.Refresh End Sub


so help somebody.... thanks in advance

Clicking On DataGrid Row Returns Values From Previously Selected Row. ??
I have a DataGrid on my form with records.

What I want to do is Click on a row and extract info from a certain column, the problem is this:

When I click, the value for Msgbox DataGrid1.Columns(0).Text shows the value from the record that was active just before I clicked. After I close the message box, then the row I had clicked on becomes active (but only after it read the data from the previous row)

What code do I put in the DataGrid1_Click Event put extract the info of the row that I clicked on?

Seems so simple...

How To Display Selected Data From Excel To VB(Flexigrid Or Datagrid)
Hi

Can somebody please help me.

I would like to select a range of data from an Excel spreadsheet and display the selected data in either a flexigrid or datagrid in VB. The problem is I don't know how.


Thank you in advance for your responses.

Kind regards

Happy

Please Help!!! Form2 Needs To Open With Selected Record On From1 - Not Datagrid Form
Problem is that I have Form1 (not datagrid) that uses db1 (access database). db1 has ID field. Form1 has a button that opens Form2. Form2 (not datagrid) that uses db2 (access database). db2 has ID field. Form1 and Form2 work fine by themselves. What I need to do is when Form1 button is clicked, Form2 showing only the records where Form1/db1 ID field matches Form2/db2 ID field. Please help!!!

 

How To Obtein A Selected Node In Blue Color When Selected In A Tree View ?
Hi all,

When I select a node in a tree view, I can't get the node in the blue
backcolor:

TreeView.Nodes(myIndex).Selected = True

How can I do this ?

Thank you for your help

Data Grid Record Selected Or Cell Text Selected?
Does anyone know how I can differentiate programmatically between a record being selected on a datagrid via the record selector arrow to the left of the grid so that the whole row is highlighted, and a cell within a row being selected.
I want to allow the user to delete the row but not delete inside a single cell.

Cheers

Open Selected File With Selected Program
hi, i want a file i selected file to open with a program i selected.
i know how to run a program with shel

d = shell("path to program",vbnormalfocus)

but then it just opens the program without the file, is their a way i can get the file to open with the program i selected?

Copyright 2005-08 www.BigResource.com, All rights reserved