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




Datagrid - Return Total Rows


Hi,
I am using a datagrid first-time and simply want to return the number of total records. Its only one column and I want to get a row count.

something like statusbar.simpletext = Their are 200 records in this datagrid.

Any help appreciated.
Thanks.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Return All Rows And Sort Rows In Excel
Hi All
I am also a new VB Programmer, Currently ,i am working on a project that link VB to Excel.I am wondering how I can return the number of rows found int he excel spreadsheet and how to sort the data?
Thank you very much for helping.

WMI Does Not Return Total Memory
Hey folks

I'm using WMI to return the total RAM from my machine. I've got 256K but my code only returns

"Total Physical Memory (kb): 228336"

Here is my code


VB Code:
Public Sub test()'* Procedure: GetMemory'* Description Returns the total physical memory 'windows management interface object.Dim WMI As ObjectDim wmiWin32Objects As ObjectDim wmiWin32Object 'total memoryDim lngMem As Long Set WMI = GetObject("WinMgmts://" & "tombsg") Set wmiWin32Objects = WMI.InstancesOf("Win32_LogicalMemoryConfiguration") For Each wmiWin32Object In wmiWin32Objects    lngMem = lngMem + wmiWin32Object.TotalPhysicalMemoryNext Debug.Print "Total Physical Memory (kb): " & lngMem End Sub


I've had a search of the forum but can't locate any related threads. Any ideas where i am going wrong.

cheers

Find Total No. Of Rows With Records
How do i check the no. of rows that contains records in excel using VB?

Return Total Items In Stock
i'm making an inventory of supplies and i'd like to get the quantity in stock of all the items at any point in time.
in MS access database i have the following three tables (and the corresponding fields):

TABLE - Field

1. INVENTORY - ItemID, ItemCategoryID
2. SUPPLY - ItemID, PurchaseDate, PurchaseQuantity
3. CONSUMPTION - ItemID, ConsumeDate, ConsumeQuantity, ReturnQuantity

INVENTORY is the main table and has one to many relationship to SUPPLY and CONSUMPTION through the ItemID field.
SUPPLY and CONSUMPTION tables, therefore, can have many entries with respect to an item. CONSUMPTION table has ConsumeQuantity and ReturnQuantity because consumption is not solely internal. Some items are 'borrowed' by staff outside the department and they just 'return/replace' it (i.e, temporary consumption)
. So at any point in time the total count of a particular item is

Totalcount = Sum(SUPPLY.PurchaseQuantity) - Sum(CONSUMPTION(ConsumeQuantity - ReturnQuantity))

Can someone help me create the right sql statement that will do this for ALL the listed items in the INVENTORY table?

Thank you in advance.

Limit Total Number Of ROWS/COLUMNS
Hi,

I'm working on a worksheet created by someone else. It has lots of VBA code included in it. The sheet itself has been formatted so that it only goes down as far as 1999 rows. Then it just stops. the rows that should be after it, doesn't appear...no row headings (numbers) or anything...just a solid color. I need to extend this back to its original form as i now have a new requirement that requires a minimum of 10,000 rows.

I get the feeling that the rows are actually still there, and i just can't see them. can someone tell me how to get these rows to appear again. I have been through all the options i can find, and no luck. Its not done by selecting a row, right clicking and then clicking "Unhide" (because how can i select something that i can't see?)

Just to clarify... There are literally NO cells below the 1999 mark. I can't select empty cells, i cant see row names(numbers), nothing. Something else that might be significant is that when the sheet is at the top, and the scroll bar is all the way up, if i grab it and move it down, it moves down in VERY large chunks. The alt message that says what row your currently on moves around 130 rows every 5mm i move the bar down. The scroll bar is the normal size that it would be on a brand new sheet though (i.e. its not really really small like it would be if there were thousands of readings)...oh, and it never changes in size.

Please, can someone tell me how to undo this very annoying formatting that my predesessor lef me with.

Thanks for any help
Pile

How To Determine Total Number Of Rows With ADODB
Hello!

Like title says, how can i determine the total number of rows in Excel 2002!?
Im using an ADODB connection to a Oracle Database.

I cannot use the excel 97' way (see example below)
recArray = rs.GetRows
recCount = UBound(rs.GetRows, 2) + 1


Any suggestions?



Edit by Moderator:
Please post database questions, in the Database and Reporting forum.

Thank you.

Total Number Of Rows Populated In ListBox
How to determine the total Number of rows populated in ListBox?

Total In Datagrid
can somebody tell me how to add total column in a datagrid
say i want to get total in column 2 of the datagrid

DataGrid Total
Heloo.


I am using the code belwo to calculate the total of a column in a datagrid, it works OK, but when the datagrid reaches hundreds of records, it display the below error message. I have to maximaize the datagrid to the highest in order for this code to work, otherwise this error message will appear with a few records.

Error Message

Invalid Row Number
======================


Code Used:

Dim total1


For i = 0 To DataGrid2.ApproxCount - 1
    
    DataGrid2.Row = i
    
   
    DataGrid2.Col = 1
        
        total1 = Val(total1) + Val(DataGrid2.Text)
Next

Text8.Text = total1


Thanks

Return Not The Desire Number Of Rows..
i have input 10 rows of data...and when i query (select) all the rows i only got the second set of 5 rows!... how come the first set of 5 rows are not shown?

Datagrid Column Total
Hello
Any One Help Me?
I have 4 columns in grid
1 itemname
2. Price
3 Qty
4 Amout
I want to amout = price*Qty at time of type value

DataGrid Column Total
Hello
Any One Help Me?
I have 4 columns in grid
1 itemname
2. Price
3 Qty
4 Amout
I want to amout = price*Qty at time of type value

Total Sum Of A Datagrid Column
 Hi All

I have a datagrid attached to an dbase app I am working on, the last column has a price value and I would like to create a total value for this column in a label or text box. I was searching back the old posts looking for some pointers or a code snippet that would do this but was unable to find anything.

Any help appreciated

Thanks

Rob



 
 

Return Number Of Rows, Integer Replacement
Hi all,

I'm looking for some code that returns the total number of rows in a spreadsheet (e.g. total number of rows - 6), and then uses that number to replace code in an existing macro.

For example, in a worksheet, 61 is the total number of rows. I'm searching for code that counts the number of rows and subtracts 6.

Here's the beginning of my code:

Rows("1:6").Select
Selection.Delete Shift:=xlUp
Columns("A:B").Select
Selection.Delete Shift:=xlToLeft
Columns("B:F").Select
Selection.Delete Shift:=xlToLeft
Range("A1:J55").Select
Selection.AutoFilter
ActiveWindow.SmallScroll Down:=-15
Range("C3").Select
Range("A1:J55").Sort Key1:=Range("C1"), Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

In this example, the total number of rows is 61, but because I'm deleting the first 6 rows at the beginning, all subsequent references to the total number of rows is 61 - 6, or 55, like J55.

Is there code that can be written that will automatically count the number of rows and subtract 6 from that returned value (before the macro is run) and replace it in the existing code (after the 6 row deletion)?

If it sounds confusing, I can further clarify upon request.

Thanks!

Total Currency In DataGrid Column
Here is the code I'm trying to use to add the currency in Column1 of a DataGrid and have it show in the txtTotal.Text textbox. I have used this a couple of years back so I just copied the code but am now getting an error here

dSum = dSum + rs("Total2")

It has something to do with rs("Total2")
Would appreciate any and all help

========================================
Dim fmtCurr As New StdDataFormat
fmtCurr.Format = "Currency"
Set DataGrid1.Columns(1).DataFormat = fmtCurr
Dim rs As ADODB.Recordset
Dim dSum As Double
Set rs = Adodc2.Recordset.Clone
rs.MoveFirst
Do Until rs.EOF
dSum = dSum + rs("Total2")
rs.MoveNext
Loop

Set rs = Nothing

txtTotal.Text = dSum
===========================

Thanks

DataGrid Total Column Count
Here is a question in VB6 you could do something like this to go through all the cells in a MSHFlexGrid1


PHP Code:





 With MSHFlexGrid1
      For iCol = 0 To MSHFlexGrid1.Cols - 1
        If iCol = 1 Then
          mstTitle = .TextMatrix(iRow, iCol)
        End If
        If iCol = 2 Then
          mstDescription = .TextMatrix(iRow, iCol)
        End If
        If iCol = 13 Then
          mstRecordID = .TextMatrix(iRow, iCol)
          GetRecordID
        End If
        stColumnHeader = MSHFlexGrid1.ColHeaderCaption(0, iCol) & ": "
        stDisplayText = stDisplayText & stColumnHeader & .TextMatrix(iRow, iCol) & vbCrLf & vbCrLf
      Next
    End With 







Now in VB.NET I am trying to do something like that when a user clicks a cell in a DataGrid.


PHP Code:





 With DataGrid2.Item(iCol, iRow)
            For iCol = 0 To DataGrid2.VisibleColumnCount
                stColumnHeader = DataGrid2.CaptionVisible.ToString & ": "
                stDisplayText = stDisplayText & stColumnHeader & DataGrid2.Item(iRow, iCol) & vbCrLf & vbCrLf
            Next
        End With 







But in this line "For iCol = 0 To DataGrid2.VisibleColumnCount" instead of DataGrid2.VisibleColumnCount I want the total column count any ideas?

Display Total In Datagrid Footer/last Row
hi i got a problem on how to display the total value of the records in each record from a database. i have populated the datagrid with the records from the database, but i dont know how to display the total amount in the last row of the datagrid.
please help..

Currency Total From Datagrid Inserted Into Txtbox
I have a datagrid that the user can edit, delete. add etc and it works fine.

The total from one currency column needs to be automaticly updated after the user makes changes and he clicks a Save cmdbutton. At the moment with this code I can only make it work by using a seperate command button to update the total. I would like to do it without using a cmdbutton to update the total. The error I get if I include the code anywhere else is you cannot add a empty row. Hopefully someone can show me how to modifiy this code.


VB Code:
If Adodc2.Recordset.RecordCount <> 0 And Adodc2.Recordset.BOF = False And Adodc2.Recordset.EOF = False ThenDim fmtCurr As New StdDataFormat fmtCurr.Format = "Currency" Set DataGrid1.Columns(1).DataFormat = fmtCurr Dim rs As ADODB.RecordsetDim dSum As DoubleSet rs = Adodc2.Recordset.Clone  rs.MoveFirstDo Until rs.EOF    If IsNumeric(rs("ValueChgOrder")) Then _            dSum = dSum + rs("ValueChgOrder")        rs.MoveNextLoop Set rs = Nothing txtTotal.Text = FormatCurrency(dSum)ElsetxtTotal.Text = "" End If


Thanks for any help

How Can I Return The Number Of Rows In Each Table Using Dynamic SQL (the Exec Statment)
Hi all I need a little help returning the number of rows in each table from the sysobjects table that bigins sys; The following is the code I have so far, it gets the names of the tables which meet the criteria. I only need to get the COUNT of rows in each table.

Code:
SELECT name AS tablename
FROM sysobjects
WHERE name LIKE 'sys%';


Any help would be greatly appreciated, Bronco

Excel Userform - Search Column For Field And Return Rows Of Data
Hello all!

I am very new to VBA, so I apologize in advance if I’m not formatting my questions appropriately.

I’m trying to create a “reporting tool” using a UserForm in Excel. There is a large master sheet full of data and the users will select which data they would like to view from the userform, click a command button, and then a smaller set of data will be viewable on the sheet. (Basically hiding rows and columns of data.)

Column A is Manager Name
Column B is Order Status

On the UserForm, users can select by Manager name to choose which records they would like to see. (Example, John Doe, Susy Q, Brad Brown)

They can also select Order Status (open, filled, cancelled).

I need some sort of code so that when the user selects “John Doe”, it searches through Column A and only returns the rows of data corresponding to John Doe. I need the same thing to happen if they select “open” for Order Status. (Searching Column B and returning corresponding rows for “open”.)

Is this possible? What type of function should be used for this?

Thanks in advance!

How To Get Total Number Of Records Of Records Return By Recordset?
I wanna get the total number of records returned by the record set. I used RecordCount, but it always return -1.
some 1 plz help me out.

Dim cnn as ADODB.Connection
Dim ars as ADODB.Recordset
set cnn = new ADODB.Connection
With cnn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:MapData.mdb;Persist Security Info=false"
.Open
End With

Dim SQL as string
SQL = " Select * from Education"
set ars = cnn.Execute(SQL)

MsgBox ars.RecordCount 'NOR WORKING???







...---.....
Hassan Zia
Hassan_Zia@mathtech-pk.com

Datagrid Rows
hi
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

Thank you.

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.

Thanks

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.Add 2
DataGrid1.Columns(2).DataField = "FamilyName"
DataGrid1.Columns(2).Caption = "Family Name"
DataGrid1.Columns.Add 3
DataGrid1.Columns(3).DataField = "Spouse"
DataGrid1.Columns(3).Caption = "Spouse' Name"
DataGrid1.HoldFields
DataGrid1.ReBind
DataGrid1.Refresh

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



VB Code:
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



VB Code:
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
Row 1
Row 2
Row 3
Row 4
Row 5
Row 6
Row 7

Now I delete Row 5. My grid will be made up like this after the deletion.
Row 1
Row 2
Row 3
Row 4
Row 6
Row 7

Instead renumbering my rows to
Row 1
Row 2
Row 3
Row 4
Row 5
Row 6

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?

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?
thanks

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

Code:
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=*****;" & _
"Password=*****;"
'Open Connection
OraRec.CursorLocation = adUseClient
OraCon.Open
'Create Recordset
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!"
Else
Set DataGrid1.DataSource = OraRec
DataGrid1.Refresh
End If
End Sub

Interchange Datagrid Rows
how do we interchange rows in a datagrid?

Transfer Rows From One Datagrid To Another
Hi,

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:


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
With fileDialog

.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.
ShowExcelFile(.FileName)


End If

End With

End Sub

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

Try

'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
'the OleDbDataAdapter.


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"))

dc.DataType.GetType("System.Boolean")
excelData.Columns.Item("Yes").DefaultValue = True


dr = excelData.NewRow
ds.Tables.Add(excelData)
DataGrid1.DataSource = ds
adapter.Fill(excelData)


'Clear any bindings from the DataGrid and set the DataSource of the DataGrid
'to the new excelData DataTable
DataGrid1.DataBindings.Clear()
DataGrid1.DataSource = excelData

Catch ex As OleDbException
MessageBox.Show(ex.Message)
Catch ex As InvalidOperationException
MessageBox.Show(Ex.Message)
Catch ex As Exception
MessageBox.Show(Ex.Message)
Finally

'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()

End Try


End Sub


'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)

Try

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))

End If

Catch ex As Exception

MessageBox.Show(ex.ToString())

End Try

End Sub



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.

End Sub
End Class

Can somebody please help? I'm new to VB and i'm using Visual Studio 2003.

Thanks,
rosmiq

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

tibor

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
Next i
Else
For i = 1 To 7
dgr.Columns(i).Locked = True
Next i
End If

or is there any other possibility i didn't think of?
thx

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?

Counting Rows In A Datagrid
Anyone know how to do that?

DataGrid And Hiding Rows
anyone know if/how to hide rows in a datagrid??

Delete Rows From A Datagrid
Hi
I want to delete records from the datagrid
here's what my datagrid look like, just a sample..ok

ABCDEF
1bbbf
2bbb
3bbbf
4bbb
5bbbf

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

End If
Next i

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
Hi everybody

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"
Else
frmFreqTable.dgSrchRes.SelBookmarks.Add rsSrchRes.Bookmark
End If

Please if anybody have an answer to this, I'll be very thankfull.

Inserting A Row In Datagrid Between Any Two Rows
Hi all,

I want to insert a row in a datagrid between any 2 rows in asp.net.
Is it possible ? If possible then how ? I am using sql server as database.



Regards,
Supriya Chakraborty

Scroll Thru DataGrid Rows
Hi Folks,

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.

CFC

CODE  
Dim i As Integer
Dim count As Integer
  
For i = 1 To grdBeneficiaries.ApproxCount
   If (g_AppUtil.GetGridColumnValue(grdBeneficiaries, 4))  <> "" Then
  count = count + 1
  End If
Next

If count = grdBeneficiaries.ApproxCount Then
    MsgBox CONST_MSG_CLOSE, vbExclamation
    Cancel = True
End If

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.

Thanks



Removing Rows From Datagrid Help
Hi All

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
Hey all,

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!

Code:
    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
    'the DataGrid.
    MajorCounter = Adodc1.Recordset.RecordCount

    With DataGrid1
        '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
            Else
                '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
            End If

            '
            'Do whatever you want to do here for each .Row
            '

            MajorCounter = MajorCounter - 1
        Loop
    End With

Highlighting Rows In Datagrid
Hi guys,
is that possible that i can highlight a or multiple rows in a datagrid (juz like in flexigrid, change the cell background into red when load)?

if yes, how can i do it?

thanks a lot

Max



Edited by - peh1696 on 4/28/2005 1:51:10 AM

# Cols, # Of Rows In Datagrid
I am using VB6 and implementing a function which autosize a datgrid. The heading is as follow:
Code:Public Sub autoResize(ByRef dGrid as dataGrid)
I am thinking of using a nested for loop which get the max textwidth of each col and row and update the column width of the datagrid. However, how can I get the number of columns and rows so that I can use this information in the for loop.

Selecting Rows In A Datagrid
Hi,

Is it possible to "know" which row is clicked upon when a user clicks in a datagrid? If so what is the method called? I have been playing with a few of the methods but haven't found anything.

I want to use the "key" of each row to open a new window with more detailed information than what is contained in the grid.

Thanks

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