Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

datagrid event question

Posted on 2004-11-10
5
Medium Priority
?
354 Views
Last Modified: 2010-04-23
I'm trying to change the value of one column based on what the user typed in another column.
So if they enter in A in the first column, the second column shows "Apple".  
I can't seem to figure out what event I should be keying off of.

Thanks in advance.
0
Comment
Question by:DennisL
  • 2
  • 2
5 Comments
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 12552602
use the CurrentCellChanged event of the DataGrid
Now here you can check whether in your particular column the user has typed A or B

Now remember, in order to set the corresponding value of Apple and Boy in the other column you'll need to assign the value to the particular column of the particular row in the Underlying table.

0
 
LVL 3

Author Comment

by:DennisL
ID: 12554874
My issue with CurrentCellChanged is that it fires everytime when you navigate through different cells.  And you can't seem to find out what the last column or row that you were in.  This program will be querying a database to populate the second column, so I don't want to be refreshing every column/row everytime the user navigates through the cells.
0
 
LVL 8

Expert Comment

by:gajender_99
ID: 12564863
hi try this

in the currentcellchanged event and also rembember that rownumber begins with 0 and column numbers also begins with 0
so row 1 is 0 and column 1 is also 0

dim r as integer
dim rowval as string
r = DataGrid.CurrentCell.RowNumber
rowval=datagrid.Item(r, 0) 'this gets the value in column 1
if rowval="A" then
datagrid.Item(r, 1)="Apple" ' this sets the value for column 2
end if
0
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 500 total points
ID: 12567298
You'll need to check whether user has selected a new Row or if he has just changed cells within the same row

For this keep a variable at Form Level wherin you'll have

DataGrid.CurrentCell.RowNumber

then in CellChanged event check if
current DataGrid.CurrentCell.RowNumber is equal to the previous value or not

eg.

Dim LastRow as Integer

Then on CurrentCellChanged

If Not LastRow=DataGrid.CurrentCell.RowNumber then
   LastRow=DataGrid.CurrentCell.RowNumber 'Store this value for next usage
   If DataGrid.CurrentCell.ColumnNumber=1 Then 'Your Column No. Here
         'Now Set the Value for the grid
   End If
End If
0
 
LVL 3

Author Comment

by:DennisL
ID: 12678070
Not exactly what I was looking for, but it does work and gave me some ideas.

I don't think I'll be using the datagrid for my next project.  haha.

Thanks for the help and sorry for accepting so late.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question