-
Oct 23rd, 2014, 11:39 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How to Show changes made to Form in VB2010
I have a Prospect Form (App1) with a Prospect displayed that contains a button, which when clicked, will display a different App (App2) that Scans a picture and updates the Prospect table with the picture of the Prospect in (App1) and then this (App2) closes, leaving App1 and the Prospect displayed.
My problem is that the only way I can get the Picture to display is to close the App1 Form and then reopen App1 Form.
I would like for the picture of the Prospect to display in App1 as soon as App2 closes.
I have tried me.refresh but that didn't work.
How can I accomplish this??
-
Oct 23rd, 2014, 12:12 PM
#2
Re: How to Show changes made to Form in VB2010
On the face of it, the problem doesn't sound all that difficult, and it sounds like you almost have it already. Whatever is happening when you close App1 Form and open it again, needs to happen in response to App2 closing. If these are really different applications, rather than different forms within a single application, that might be a bit harder, as you have to communicate between the two by some means. If App1 is launching App2, then there may be some direct communication already. If App1 and App2 are both sharing a DB, but are otherwise independent of each other, then you have to have a way for them to communicate. There are a variety of methods that can do this, such as UDP, named pipes, and others, but before going down that path, how about just explaining the relationship between the two apps a bit more: Do they communicate by any means already? Are they really independent apps, or different parts of the same one?
My usual boring signature: Nothing
-
Oct 23rd, 2014, 12:39 PM
#3
Re: How to Show changes made to Form in VB2010
If App2 updates the Prospect table with the picture then it seem that you could just requery the Prospect table from App1 when App2 closes.
-
Oct 23rd, 2014, 01:18 PM
#4
Thread Starter
Hyperactive Member
Re: How to Show changes made to Form in VB2010
Thanks for the response.
I actually misspoke as they say in politics.
App1 and App2 are completely independent of each other but both work on the same Prospect table.
The user clicks a button on the appropriate Prospect currently displayed in App1 that displays a message telling him to scan in a drivers license, but then does nothing after this message.
The user then inserts a drivers license in a scanner which automatically starts App2 and scans in the pic and other info which automatically updates the Prospect table with this info and then automatically closes, leaving the user looking at his prospect on the Prospect screen in App1.
My problem is the Pic and other scanned doesn't show at this point, nor if he moves to another row and back. He has to close the screen and then reopen the screen for the pic and new info to show.
-
Oct 23rd, 2014, 02:11 PM
#5
Re: How to Show changes made to Form in VB2010
That makes sense, but it doesn't make it easy. It sounds like there is no event that App1 can detect that lets them know that App2 has closed and that updates are ready. It seems to me that you have two alternatives:
1) If you have written both App1 and App2, such that you can make changes to both, then you could have the two communicate directly. I'd use UDP for that, but only because that's where I have experience. There are probably better tools available.
2) Alternatively, you could add a timer in App1 and have it keep checking the DB for changes. If App1 is going to be sitting while App2 is active, then the timer could check every second, or so, withouth causing a great deal of lag. You could check more frequently if you wanted App1 to respond faster to changes, but checking once a second seems like it would be fast enough. The maximum time you would have to wait before App1 recognized the change would be twice the interval of the timer, so if the interval is 1 second, the maximum lag would be 2 seconds, which doesn't seem all that bad.
My usual boring signature: Nothing
-
Oct 23rd, 2014, 03:20 PM
#6
Thread Starter
Hyperactive Member
Re: How to Show changes made to Form in VB2010
Thanks for the responses. It is really no problem because App2 Shows a form (on top of App1) with buttons that the user clicks to choose between scanning a Buyer Pic or a CoBuyer pic. After the scan is complete and the Prospect table updated, App2 closes leaving only App1 displayed.
The App1 dataset contains all of the Prospect rows that belong to that particular Salesperson. Now I'm back at the problem where I need for the Pic to display. Let me try the requery solution that Wes4dbt suggested.
-
Oct 23rd, 2014, 03:52 PM
#7
Thread Starter
Hyperactive Member
Re: How to Show changes made to Form in VB2010
Well, I'm making progress, but still no cigar.
I am using the code below but I have to physically click MoveNext and then Click MovePrevious on the Forms BindingNavigator to get the picture to display. What coding changes do I need to make??
Private Sub ButtonRefresh_Click(sender As System.Object, e As System.EventArgs) Handles ButtonRefresh.Click
Cursor = Cursors.WaitCursor
HoldProsNum = txtProsNumKey.Text
If ModLogonMgrOrSp = "MGR" Or ModLogonMgrOrSp = "ADMIN" Then
Me.ProspectTableTableAdapter.Fill(Me.DeiDatabaseDataSet8.ProspectTable)
Else
Dim SpName As String = ModLogonLNFN
Me.ProspectTableTableAdapter.FillBySalesperson(Me.DeiDatabaseDataSet8.ProspectTable, SpName)
End If
Dim aa As Integer = Me.ProspectTableBindingSource.Find("PProspectNumKey", HoldProsNum)
Me.ProspectTableBindingSource.Position = aa
Me.ProspectTableBindingSource.MoveNext()
Application.DoEvents()
aa = Me.ProspectTableBindingSource.Find("PProspectNumKey", HoldProsNum)
Me.ProspectTableBindingSource.Position = aa
Application.DoEvents()
Me.Refresh()
Cursor = Cursors.Default
End Sub
-
Oct 23rd, 2014, 04:30 PM
#8
Re: How to Show changes made to Form in VB2010
Don't have time to test right now but maybe the App1 form "GotFocus" event will trigger when you close App2. You could set some type of flag that when True it would requery the table and what ever it take to display what you want.
-
Oct 23rd, 2014, 04:51 PM
#9
Thread Starter
Hyperactive Member
Re: How to Show changes made to Form in VB2010
The code in Post #7 above is in App1 which the user will Click.
The ReQuery works file. My problem now is that the user will need to physically click MoveNext and then Click MovePrevious on App1 Form's BindingNavigator to get the picture to display. What coding changes do I need to make so the User will not have to click the BindingNavigator for the Pic to display??
Note: for you sharp guys that are probable wondering about this, I am trapping the "Concurrency Violation" in App2 when it updates the prospect table that is open in App1 on the row that is updated!
Last edited by DexterRose; Oct 23rd, 2014 at 05:14 PM.
-
Oct 23rd, 2014, 05:57 PM
#10
Re: How to Show changes made to Form in VB2010
Note: for you sharp guys that are probable wondering about this, I am trapping the "Concurrency Violation" in App2 when it updates the prospect table that is open in App1 on the row that is updated!
You shouldn't have a Concurrency Violation if you save the updates from App1 before you open App2.
As for why you have have to click movenext for the updates to appear, I don't have and answer. I tested using two separate form and the changes showed up with just executing the Fill method on the tableadapter.
Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim frm As New Form5
frm.ShowDialog()
Me.TagsdetailBindingSource.EndEdit()
Me.TagsdetailTableAdapter.Fill(Me.WaterDbDataSet.tagsdetail)
End Sub
-
Oct 23rd, 2014, 07:15 PM
#11
Thread Starter
Hyperactive Member
Re: How to Show changes made to Form in VB2010
Thanks again for the help.
I added the EndEdit line before my Fill instruction and now the text changes appear when I click the ButtonRefresh but I have to move to the next row and then back for the Picture to appear.
-
Oct 23rd, 2014, 07:42 PM
#12
Re: How to Show changes made to Form in VB2010
did you try:
Code:
DataGridView1.EndEdit()
?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 23rd, 2014, 07:44 PM
#13
Re: How to Show changes made to Form in VB2010
after the Fill instruction that is
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 23rd, 2014, 07:47 PM
#14
Re: How to Show changes made to Form in VB2010
another 2 possible solutions are:
DataGridView1.InvalidateCell()
DataGridView1.RefreshEdit()
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 24th, 2014, 07:35 AM
#15
Thread Starter
Hyperactive Member
Re: How to Show changes made to Form in VB2010
Thanks to everyone for your help on this!!
Well, I woke up in the middle of the night and remembered that the Picture was not carried in my table but just the drivers license number. I remembered that I had code in the BindingNavigator routine to load the picture into a picturebox on my form, which was why the pic did not show on my latest changes. One Call to this routine solved that problem.
The EndEdit code before the Fill instruction solved my original problem as I referred to before.
Thanks again to everyone for helping on this!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|