Data grid urgent help....very urgent

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2008
Posts: 126
Reputation: laghaterohan is an unknown quantity at this point 
Solved Threads: 1
laghaterohan laghaterohan is offline Offline
Junior Poster

Data grid urgent help....very urgent

 
0
  #1
Oct 3rd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: Data grid urgent help....very urgent

 
0
  #2
Oct 3rd, 2008
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?
Dim i = e.RowIndex
Dim j = e.ColumnIndex
txtefid.Text = dgfacenq.Item(i, j).Value
/// You did realize that this was the same thing repeated right after the first just in a different look right?
Dim i = e.RowIndex Dim j = e.ColumnIndex txtefid.Text = dgfacenq.Item(i, j).Value
In effect if you have this code this way in your program you've just done this

  1. Dim i = e.RowIndex
  2. Dim j = e.ColumnIndex
  3. txtefid.Text = dgfacenq.Item(i, j).Value
  4.  
  5. Dim i = e.RowIndex
  6. Dim j = e.ColumnIndex
  7. txtefid.Text = dgfacenq.Item(i, j).Value
Last edited by rapture; Oct 3rd, 2008 at 3:40 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 122
Reputation: manal is an unknown quantity at this point 
Solved Threads: 17
manal's Avatar
manal manal is offline Offline
Junior Poster

Re: Data grid urgent help....very urgent

 
0
  #3
Oct 3rd, 2008
When i click on the ID field that id should get displayed in the ID TEXT FIELD...
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

  1. Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseUp
  2. TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, NumOfIDColumn)
  3. End Sub
DataGrid1.CurrentCell.RowNumber will return current cell that user select
NumOfIDColumn refers to the ID column in your dataset if it's the first column then you will write

  1. 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 "
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 126
Reputation: laghaterohan is an unknown quantity at this point 
Solved Threads: 1
laghaterohan laghaterohan is offline Offline
Junior Poster

Re: Data grid urgent help....very urgent

 
0
  #4
Oct 5th, 2008
thanks for your timely help!

cya
Rohan


Originally Posted by manal View Post
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

  1. Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseUp
  2. TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, NumOfIDColumn)
  3. End Sub
DataGrid1.CurrentCell.RowNumber will return current cell that user select
NumOfIDColumn refers to the ID column in your dataset if it's the first column then you will write

  1. 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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 126
Reputation: laghaterohan is an unknown quantity at this point 
Solved Threads: 1
laghaterohan laghaterohan is offline Offline
Junior Poster

Re: Data grid urgent help....very urgent

 
0
  #5
Oct 5th, 2008
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 :
  1. DataGrid1.Item(DataGrid1.CurrentCell.RowNumber,0)
with ofcourse modification accordingly i get error as to System.........cannot convert to String. So i add
  1. DataGrid1.Item(DataGrid1.CurrentCell.RowNumber,0).ToString
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 !
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 122
Reputation: manal is an unknown quantity at this point 
Solved Threads: 17
manal's Avatar
manal manal is offline Offline
Junior Poster

Re: Data grid urgent help....very urgent

 
0
  #6
Oct 5th, 2008
Is it necessary to write only under MouseUp? Why not under Cell Click / CellContent Click?
o, not necessary but I thought it will work
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 "
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum


Views: 1307 | Replies: 5
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC