|
Setting 'CheckForIllegalCrossThreadCalls' to false won't help you in this case. I tried it myself and I get the same error you do. You could do that way if you were changing the text of a control or something like that, but I don't think you should use that method in any circumstances. I don't know that for sure but I would guess not using that method is the recommended way to go. Here is a procedure you can call to safely add a control to the collection of another from any thread.
Delegate Sub AddControlDelegate(ByVal parent As Control, ByVal child As Control)
'Safely adds any control to the collection of another
'parent: The control that is the container
'child: The control to add
Private Sub AddControl(ByVal parent As Control, ByVal child As Control)
If parent.InvokeRequired Then
parent.Invoke(New AddControlDelegate(AddressOf AddControl), New Object() {parent, child})
Else
parent.Controls.Add(child)
End If
End Sub
Now when you want to add your label you just use this procedure to safely do it from any thread you wish.
AddControl(me,lbl(Lindex)) For a more in depth tutorial on updating the UI from secondary threads you should read this article http://msdn.microsoft.com/msdnmag/issues/04/05/BasicInstincts/default.aspx[^] and/or search the web. For the moment though you just need to know my procedure works
-- modified at 4:38 Saturday 17th February, 2007
|
|
|
|
|
|
Below my DropDownList bound with a Department table.Following Output iam getting,IT,CSE,Mech-these all from table.but i want an "ALL" text also there in list box..How come this possible?
Sub bindDtgrid()<br />
With dtgEmplList<br />
.DataSource = myDataSet<br />
.DataMember = myDataSet.Tables(0).TableName<br />
.DataBind()<br />
End With<br />
End Sub
Praveen.K
System Engineer
Graviton Technologies Pvt.Ltd
|
|
|
|
|
Hi
Please advise me how to enter a new row in Microsoft Access Database by using vb.net.
regards
adil
|
|
|
|
|
R u kidding asking such a question in this forum...You shud first search that into google or any other search engine, then try it yourself and if you are facing any problem then post it here so that we can help you out. We are not here for spoon feeding. please avoid such stuff in future.
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|
|
hi dear
I tried to find a lot ...as i am new to vb.net therefore suffering to solve my problem.
I used following code to retrive data..
Now i want to insert...but unable to do so...
Imports System.Data.OleDb
Public Class Form1 Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e as _
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles Button1.Click
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_
Data Source=C:\emp.mdb;")
'provider to be used when working with access database
cn.Open()
cmd = New OleDbCommand("select * from table1", cn)
dr = cmd.ExecuteReader
While dr.Read()
TextBox1.Text = dr(0)
TextBox2.Text = dr(1)
TextBox3.Text = dr(2)
' loading data into TextBoxes by column index
End While
Catch
End Try
dr.Close()
cn.Close()
End Sub
End Class
regards
adil
m.adil.farooq
mcs & acca
adil-farooq@maktoob.com
|
|
|
|
|
you can try to use dataset or
oledbcommand with insert command and parameter
to create new row
|
|
|
|
|
I want to pop up a dialog box when the user disturbs the screensaver. Both the MsgBox and the InputBox work. When I try to pop up my own form using MyForm.ShowDialog(), it doesn't work. What's the difference between those boxes and mine? What do I have to do to make mine work like they do?
I'd use the Input box, but it is SO ugly!
JimT
|
|
|
|
|
Hi!
I have a question, how can open a pdf file?, i know what we can download a pdfkit, but, is possible open a pdf file without this kit?, by vb.net only?
Cuando salga el sol, no estare aqui...
|
|
|
|
|
You can open and read the file in Binary mode all you want. The .NET Framework doesn't have any support for interpreting and manipulating the contents of a PDF file though. If you wanted to manipulate the file, you'd have to have a library to do it for you, like the PDF.NET or something similar.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I understand, thanks very much for yours replies.
Cuando salga el sol, no estare aqui...
|
|
|
|
|
System.Diagnostics.Process.Start("\\Whateverpath\YourDocument.pdf")
The client just needs to have adobe reader on their system.
Lost in the vast sea of .NET
|
|
|
|
|
DateTime.Now.DayOfYear
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
i have an com application which keeps track of another application and displays the message accordingly made in vb6.
but it gives error70 when we handle the application to and fro very frequently.
can anyone help me on Error-70 or any idea about the possible reasons.
thanks in advance
amolk
|
|
|
|
|
It most likely means your remote COM server is busy or stopped. Basically, your app made a call to this COM server and the call timed out. You probably have a performance issue with your COM server.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
Thanks, i tried to get rid for the issue. now i'm thinking to convert code from the dll into exe, so even if the server is busy or timed out , we don't get the error in running application. can you please suggest is it possible or not and how.
thanks,
amolk
amolk
|
|
|
|
|
Just converting it to an .EXE won't do anything. It appears as if you have a performance problem with your server code. You have to figure out what that performance issue is and correct it. The questions you have to start asking yourself are: Which method has the problem and why is it taking so long to return a result? Is there another way to implement this class to respond faster?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
Thanks for your suggestion, i trace that error is due to clients' next request before the first complets and then there is no room to show the result for first one , hence if user sends request very fast the com gets busy and returns the error, while if user goes sequentially then the results are appropriate.
with regards,
amolk
|
|
|
|
|
Hi,
I'd like to copy an image with the File.Copy option. But, if i have the image loaded in a picturebox, it won't copy because the file is in use. I tried the picturebox.dispose option, but then i get an error message saying: invalid parameter used. Can anyone help me with copying an image loaded in a picturebox?? Thanks, Zaegra
--Zaegra--
|
|
|
|
|
I have seen some weird stuff where with images where you need to manually do Garbage Collection. I don't know for sure if that will help in your situation.
GC.Collect
Ben
|
|
|
|
|
If you are trying to copy an image, then it shouldn't matter if the file is being used or not. Do you mean that you are trying to move the image?
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
An image file loaded by Image.FromFile or some other method is held open for the life of the image object. The workaround is surprisingly simple... here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks guys, that helped me out
--Zaegra--
|
|
|
|
|
Hi,
I have 1 subreport on my main crystal Report.
I want to calculate Total of fields. one field from 1st main report & 2nd field from my subreport . Will Anyone Tell me how to do it.
i m using vb.net &crystal rpt.
-thanks
priya
|
|
|
|
|
For this i think u need include the table of subreport,
then make a formula to calculate that fields value...
it will display the total of both main report's field & sub report's field
Thanks,
Ankur Bakliwal
|
|
|
|