|
What i'm trying is:
I have 1 form ( form1 ) that when i click in a button open another form ( form2 ) with a datagrid where i can select one user with a keypress or a doubleclick. After that, the form2 closes automatically and i want that the data in the row selected on datagrid goes to textboxs in form1. I have the data in one dataset.
How you would decide this problem?
Can you tell me the better way to do that?
thanks for the help.
|
|
|
|
|
I would suggest using Events to perform what you would like to do. I posted a link earlier, but I'm assuming you haven't read it.
http://www.devcity.net/Articles/94/multipleforms.aspx[^]
Anyway, since you are not willing to read the link...here is some sample code:
In Form2 (the one with a Datagrid):
<br />
Public Class Form2<br />
Inherits System.Windows.Forms.Form<br />
<br />
#Region " Windows Form Designer generated code "<br />
...<br />
#End Region<br />
<br />
'declare an event that can be caught in Form1 code<br />
'you can name this whatever you want<br />
Public Event OnRowDoubleClicked()<br />
<br />
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
'databind your datagrid here or in design mode<br />
End Sub<br />
<br />
Private Sub DataGrid1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick<br />
'This is if you want to close your window on a when <br />
'the user double clicks a row<br />
<br />
'raise the event to be caught in Form1<br />
RaiseEvent OnRowDoubleClicked()<br />
<br />
Me.Close()<br />
End Sub<br />
<br />
Private Sub Form2_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) _<br />
Handles MyBase.Closing<br />
'cancel closing of form<br />
e.Cancel = True<br />
'hide the form from the user<br />
Me.Hide()<br />
End Sub<br />
End Class<br />
Now in Form1 (the one with the Button and TextBox):
<br />
Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
<br />
#Region " Windows Form Designer generated code "<br />
...<br />
#End Region<br />
<br />
'declare a Form2 with events - the key to handling the <br />
'doubleclick in Form2<br />
Private WithEvents f2 As Form2<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
'display the form to the user<br />
<br />
'check if Form2 has been created<br />
If Not f2 Is Nothing Then<br />
If Not f2.IsDisposed Then<br />
'display form if not disposed<br />
f2.ShowDialog()<br />
Else<br />
'create new instance of Form2<br />
f2 = New Form2<br />
f2.ShowDialog()<br />
End If<br />
Else<br />
'create new instance of Form2<br />
f2 = New Form2<br />
f2.ShowDialog()<br />
End If<br />
<br />
End Sub<br />
<br />
<br />
Private Sub f2_OnRowDoubleClicked() Handles f2.OnRowDoubleClicked<br />
'handle the double click event in the datagrid of Form2<br />
'now you can access the Datagrid information since it is a public control <br />
'in Form2...like so:<br />
TextBox1.Text = f2.DataGrid1....<br />
End Sub<br />
End Class<br />
It's up to you to figure out the rest...but I really do suggest you read the article that I linked!
A.S.
|
|
|
|
|
Thanks for everything.
It works very well.
Persons like you makes the codeproject big.
One more time, Thanks.
|
|
|
|
|
Can a tuple within a table hold a URL that points to a particular file, so that when a SELECT is made on that tuple it will open up the file itself?
|
|
|
|
|
SQL questions belong in the SQL Forum[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
No, a SELECT is only going to select data, not realise it's a URL, let alone visit it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks in advance,
I have developed a small application in VB6.0 which prints on a predefined paper. As of now its printing fine on EPSON printer. But when i run the same application and printing on HP/Other printer its printing different.( i mean not in the defined areas). To say, if in EPSON, if its printing from left side, in HP its printing from right side and the print is totally outside my paper. How can i control this? Is it that some printers print from left side and some printers print from right side? How to achieve this through visual basic, no matter what the clients printer is.. it should print in the predefined areas. I will be looking forward for a reply. Thanks again
Electronic Screw
|
|
|
|
|
That's going to be a bit difficult to do. Since each printer has different "unprintable margins," it's virtually impossible to do what you want completely automatically.
For example, if a field is about an inch from the left edge of the page, the unprintable margin on one printer would probably be something like 1/8" and on another 3/16".
You'll have to put into your code some method for your fields to be laid out using offsets. These offsets would be stored in an .INI file and read by your program. Using these offsets, you're code could move the fields around so they fall into the pre-printed boxes on the form. You'll have to come up with the method for moving them around depending on how your laying them out now.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am running MSI installs from my program but because they use msiexec.exe and not the .msi file it is hard to know when they have finished.
I am trying to create a list of running processes and check if msiexec.exe is still running so then i will know when the install has finished.
Can anyone help on this?
Thanks Oli
|
|
|
|
|
Msiexec returns a code that indicates success or error information. If msiexec returns a zero the setup has finished successfully. But there is a whole page of codes that can be returned. You should download the Windows Installer documentation from MS to get the more information.
|
|
|
|
|
How can i monitor the msiexec for an exit code after i have ran the msi exe?
Thanks
Oli
|
|
|
|
|
Try
Dim ExitCode As Integer
Dim si As New ProcessStartInfo()
si.FileName = "msiexec"
'Add install switch and quotes to msi path
si.Arguments = " /i " & """" & strMSIPath & """"
Dim proc As Process = Process.Start(si)
proc.WaitForExit()
ExitCode = proc.ExitCode
Catch ex As Exception
'All real exit codes are >= 0
ExitCode = -1
End Try
'Evaluate Exit Code ....
|
|
|
|
|
Hi
I have a to create a lookpup Table in VB.Net where in i have values like this
1 = 1.9
2 = 3.4
3 = 4.5
I know i can't use Enum. Which is the best way of storing these values in a class ?
Thanks
|
|
|
|
|
A hashtable, or if the numbers are sequential ( i.e. 1,2,3,4,5,6 ), an array.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
how to start to write d coding for voice recognition.. anyone have any idea?
|
|
|
|
|
Start by not using VB.NET, I'd use C++ for this, for sure.
Next, if your first approach is to ask such a vague question in a forum, wait a few years and try again.
Microsoft has a speech recognition SDK if you just want to add it to an app you're working on. I have no idea how good it is.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Hi,
I have an input form with quite a few textboxes. When I tab to one of these textboxes I want it to highlight the complete data and not just put the cursor at the end of the data. This means that the user can overtype the data instead of deleting and then typing.
Any help appreciated
|
|
|
|
|
Give this a try:
To handle one text box:
<br />
Private Sub TextBox1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Enter<br />
'select all text in the text box<br />
TextBox1.SelectAll()<br />
End Sub<br />
To handle multiple text boxes:
<br />
Private Sub TextBox1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Enter, TextBox2.Enter, TextBox3.Enter<br />
Ctype(sender,TextBox).SelectAll()<br />
End Sub<br />
Note: Text is selected when the user tabs into the Textbox
|
|
|
|
|
Cheers
Worked a treat !!
|
|
|
|
|
--------------------------------------------------------------------------------
Hi,
We have VB6 application up and running having SQL 2k as database. It has about 50 and more user using at pick hrs.
Now the problem is, sometime, few user got error message and kicked off from the application. I analyze windows eventlog and found that type of error is DrWatson and some exception thrown for multibytetowidchar kind of.
I really don't have any idea what happening here. If anybody have any little idea abt this I can give descriptive and exact explaination to them and will discuss further.
Thanks
Viral
|
|
|
|
|
Without the EXACT error message, it's not even possible to do a meaning ful search on it. Since we have no idea what your code is even doing at the time of the problem and MultiByteToWideChar is part of the Win32 and is used inside all VB6 apps extensively, this could be, literally, caused by anything in your app.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Error message on User's screen
"Child.exe has generted erros and will be closed by Windows. You will need to restart the program. An error log is being create."
Error message in error log - error log retrive form event viewer of administrative tool.
Type – Information
Source – DrWatson
Description - The application, , generated an application error The error occurred on 07/19/2005 @ 08:20:47.979 The exception generated was c0000005 at address 7C5B89AE (MultiByteToWideChar)
Can you help me out with this information.
If you want something more / else... write me up.
I am trying to find out the pattern of the error.
Let hope for the best.
|
|
|
|
|
There's just not enough information to pin this down, but, it could be caused by a badly formed SQL statement. If your code is using string concatenation to build SQL queries, like
Dim mySQLStatement As String
mySQLStatement = "SELECT * FROM sometable WHERE field1=" & somevariable & " AND field2 Like '" & something & "'"
you'll problably have problems that you can't trace down.
You might also try upgrading the MDAC to the latest version.
This is one of those problems that is very generic in nature and is not going to be solved easily. If you don't have to source code for the app, you're pretty much out of luck.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
We got the source code at last...
Now what would be your approach to trace down this proble.
What you suggest to eliminate this error?
Just let you know, that this problem is not consistant and pops up in few forms till now. After kicking out from the application, user do the same thing again, it will work fine.
Viral
|
|
|
|