943,568 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 496
  • VB.NET RSS
Apr 28th, 2009
0

query

Expand Post »
sir i am developing application in windows so i want that when i serach data that data then that data is dislpayed indatagridview when i am doing that thecvdata is displayed but there is one blank row created in gridview below that row:means that suppose in first row of gridview tge serach data is there and below that an emnpty row is created .so how i block to create an empty row
i do search in keydown event
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
arunasingh is offline Offline
39 posts
since Dec 2008
Apr 28th, 2009
0

Re: query

If you don't want the blank row to be shown you have to set the 'enable adding' property in the designtime to be false.
Reputation Points: 33
Solved Threads: 10
Junior Poster in Training
4advanced is offline Offline
67 posts
since Nov 2008
Apr 28th, 2009
0

Re: query

if i set enable adding to false it gives error index out of range
Reputation Points: 10
Solved Threads: 0
Light Poster
arunasingh is offline Offline
39 posts
since Dec 2008
Apr 28th, 2009
0

Re: query

At which point it generates that error? If the index is out of range you're trying to get a non existing row in the collection of rows......

Could you show some code?

Regards
Reputation Points: 33
Solved Threads: 10
Junior Poster in Training
4advanced is offline Offline
67 posts
since Nov 2008
Apr 29th, 2009
0

Re: query

con = New OleDbConnection(constr) adpt = New OleDbDataAdapter("select * from drs_entry_list where drsno='" + DrsnoToolStripTextBox.Text + "' order by srno", con)
ds = New DataSet
adpt.Fill(ds)
If ds.Tables(0).Rows.Count - 1 >= 0 Then
For j As Integer = 0 To ds.Table0).Rows.Count - 1
Dim org As String = ds.Tables(0).Rows(j).Item(4) DataGridView1.Rows(DataGridView1.Rows(j).Cells(0).rowindex).Cells(5).Value = org.ToString
Dim AWBNO As Integer = ds.Tables(0).Rows(j).Item(1)
DataGridView1.Rows(DataGridView1.Rows(j).Cells(1).RowIndex).Cells(1).Value = AWBNO.ToString

Next
End If
End If


in this when i search through drsno the in datagridview it gives error :Index was out of range : i need that row is fetched and below it no empty row is created and when i press enter in any cell of datagridview a bove row ios copied as second row in datagridview
Reputation Points: 10
Solved Threads: 0
Light Poster
arunasingh is offline Offline
39 posts
since Dec 2008
Apr 29th, 2009
0

Re: query

First, it's better to organize your code and make it readable

con = New OleDbConnection(constr) 
adpt = New OleDbDataAdapter("select * from drs_entry_list where drsno='" + DrsnoToolStripTextBox.Text + "' order by srno", con)
ds = New DataSet
adpt.Fill(ds)

Dim MyTable as DataTable = ds.Tables(0)

If MyTable.Rows.Count - 1 >= 0 Then

etc etc etc.

Second, if no records has been found, the code If MyTable .Rows.Count - 1 >= 0 will raise an error because "Rows.Count = 0" and it cannot be decreased -1

Check if Rows.Count > 0
Last edited by 4advanced; Apr 29th, 2009 at 4:31 am.
Reputation Points: 33
Solved Threads: 10
Junior Poster in Training
4advanced is offline Offline
67 posts
since Nov 2008
Apr 29th, 2009
0

Re: query

thanku for thias it is working , next i want to set focus from one cell to another of datagridview on pressing enter in datagridview cell
Reputation Points: 10
Solved Threads: 0
Light Poster
arunasingh is offline Offline
39 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: focus query
Next Thread in VB.NET Forum Timeline: Desktop Short cuts to application





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC