| | |
Data grid urgent help....very urgent
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2008
Posts: 126
Reputation:
Solved Threads: 1
hello,
I get my values displayed in the datagrid on the click of search button.
In that datagrid there are several fields....among them one is the ID field....
When i click on the ID field that id should get displayed in the ID TEXT FIELD...
Well, below is the code for the same which i have wrote on the Cell click event
Help with Code Tags
(Toggle Plain Text)
Dim i = e.RowIndex
Dim j = e.ColumnIndex
txtefid.Text = dgfacenq.Item(i, j).Value
Dim i = e.RowIndex Dim j = e.ColumnIndex txtefid.Text = dgfacenq.Item(i, j).Value
HOWEVER THE PROBLEM IS that when i get more thatn 1 row displayed in the datagrid and if i click on any row except row 1 , the value of that ID is not displayed in the textfield !
Whats the prob?? any problem regarding increment ??
PLZ HELP ME OUT ITS VERY URGENT !!! PLZZZ WHT SHOULD ID DO TO OVERCUM THIS PROB ??
CYA
ROHAN
I get my values displayed in the datagrid on the click of search button.
In that datagrid there are several fields....among them one is the ID field....
When i click on the ID field that id should get displayed in the ID TEXT FIELD...
Well, below is the code for the same which i have wrote on the Cell click event
Help with Code Tags
(Toggle Plain Text)
Dim i = e.RowIndex
Dim j = e.ColumnIndex
txtefid.Text = dgfacenq.Item(i, j).Value
Dim i = e.RowIndex Dim j = e.ColumnIndex txtefid.Text = dgfacenq.Item(i, j).Value
HOWEVER THE PROBLEM IS that when i get more thatn 1 row displayed in the datagrid and if i click on any row except row 1 , the value of that ID is not displayed in the textfield !
Whats the prob?? any problem regarding increment ??
PLZ HELP ME OUT ITS VERY URGENT !!! PLZZZ WHT SHOULD ID DO TO OVERCUM THIS PROB ??
CYA
ROHAN
•
•
Join Date: Jul 2007
Posts: 276
Reputation:
Solved Threads: 37
You only handle one value with what you have here. Think about it - how many i's can you have with what you have below? How many j's?
I understand you think since i,j would be different for each row,column that you have it covered but you only have one of each specified. In addition, you don't have anything like a foreach or any other statement that will iterate through more than the first one. How does the program know that you have more than one and to grab them as well?
Maybe you have more code that you didn't post?
/// You did realize that this was the same thing repeated right after the first just in a different look right?
In effect if you have this code this way in your program you've just done this
I understand you think since i,j would be different for each row,column that you have it covered but you only have one of each specified. In addition, you don't have anything like a foreach or any other statement that will iterate through more than the first one. How does the program know that you have more than one and to grab them as well?
Maybe you have more code that you didn't post?
•
•
•
•
Dim i = e.RowIndex
Dim j = e.ColumnIndex
txtefid.Text = dgfacenq.Item(i, j).Value
•
•
•
•
Dim i = e.RowIndex Dim j = e.ColumnIndex txtefid.Text = dgfacenq.Item(i, j).Value
VB.NET Syntax (Toggle Plain Text)
Dim i = e.RowIndex Dim j = e.ColumnIndex txtefid.Text = dgfacenq.Item(i, j).Value Dim i = e.RowIndex Dim j = e.ColumnIndex txtefid.Text = dgfacenq.Item(i, j).Value
Last edited by rapture; Oct 3rd, 2008 at 3:40 pm.
•
•
•
•
When i click on the ID field that id should get displayed in the ID TEXT FIELD...
VB.NET Syntax (Toggle Plain Text)
Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseUp TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, NumOfIDColumn) End Sub
NumOfIDColumn refers to the ID column in your dataset if it's the first column then you will write
VB.NET Syntax (Toggle Plain Text)
DataGrid1.Item(DataGrid1.CurrentCell.RowNumber,0)
Note that even when user clicked the Name column in first row , the program will still display the ID in textbox
see this link
I hope that will help you
Last edited by manal; Oct 3rd, 2008 at 8:39 pm.
"give only what u willing to receive "
•
•
Join Date: Aug 2008
Posts: 126
Reputation:
Solved Threads: 1
thanks for your timely help!
cya
Rohan
cya
Rohan
•
•
•
•
do you mean display it on TextBox? if yes then use MouseUp event handler inorder to know when user select the cell, and then display the cell content in textbox
DataGrid1.CurrentCell.RowNumber will return current cell that user selectVB.NET Syntax (Toggle Plain Text)
Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseUp TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, NumOfIDColumn) End Sub
NumOfIDColumn refers to the ID column in your dataset if it's the first column then you will write
VB.NET Syntax (Toggle Plain Text)
DataGrid1.Item(DataGrid1.CurrentCell.RowNumber,0)
Note that even when user clicked the Name column in first row , the program will still display the ID in textbox
see this link
I hope that will help you
•
•
Join Date: Aug 2008
Posts: 126
Reputation:
Solved Threads: 1
HI...i am not getting the desired output! i mean i am getting only errors.
Firstly have written that code under the MouseUp event of my datagrid .Is it necessary to write only under MouseUp? Why not under Cell Click / CellContent Click?
when i take my mouse over my id which is the first row in the datagrid nothing appears in the text box.
Yeah before that when i write this code :
with ofcourse modification accordingly i get error as to System.........cannot convert to String. So i add
Is it correct ??
If i click on the cell i get another bigggggggg error....
Plz help me out soon ! plzzzz awating your quick response..
C my prob is :
I search the name of the enq. . When the particular say xyz enq.is found it appears in the datagrid below along with its id and other details.
So now when i will click on the ID ( first Column,row in the datagrid) that same id should appear in the TEXTBOX.
Plzzzzzzzz help me out !
Firstly have written that code under the MouseUp event of my datagrid .Is it necessary to write only under MouseUp? Why not under Cell Click / CellContent Click?
when i take my mouse over my id which is the first row in the datagrid nothing appears in the text box.
Yeah before that when i write this code :
VB.NET Syntax (Toggle Plain Text)
DataGrid1.Item(DataGrid1.CurrentCell.RowNumber,0)
VB.NET Syntax (Toggle Plain Text)
DataGrid1.Item(DataGrid1.CurrentCell.RowNumber,0).ToString
If i click on the cell i get another bigggggggg error....
Plz help me out soon ! plzzzz awating your quick response..
C my prob is :
I search the name of the enq. . When the particular say xyz enq.is found it appears in the datagrid below along with its id and other details.
So now when i will click on the ID ( first Column,row in the datagrid) that same id should appear in the TEXTBOX.
Plzzzzzzzz help me out !
•
•
•
•
Is it necessary to write only under MouseUp? Why not under Cell Click / CellContent Click?
Because I remember that when I once used click event it was fired only when I click the header of datagrid not the cell content
, you can try (or search on net) for what each event do "give only what u willing to receive "
![]() |
Similar Threads
- Creating a popup menu on mouse over (JavaScript / DHTML / AJAX)
- dropdown list (VB.NET)
- data grid.... very urgent...... (C#)
- search problem in vb (Visual Basic 4 / 5 / 6)
- asp.net help needed URGENT (ASP.NET)
- Need Urgent Solution (Visual Basic 4 / 5 / 6)
Other Threads in the VB.NET Forum
- Previous Thread: Will any one plz help me ??
- Next Thread: Visual basic programin 2008
Views: 1306 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
"crystal .net .net2005 30minutes 2008 access application arithmetic array assignment basic binary box button buttons center code combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dll dosconsolevb.net editvb.net error excel firewall folder highlighting image images isnumericfuntioncall listview login math memory mobile ms mssqlbackend mysql navigate net opacity pan peertopeervideostreaming picturebox picturebox1 plugin port print printing printpreview problem problemwithinstallation project record reports" reuse save savedialog serial server sorting sql storedprocedure string structures studio temp textbox timer updown upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





