|
Hi Erik, it is me clearly.
DataAdapter has filled the tables in the dataset, i Can export to xml. More then 2000 rows.
DataGridView shows the data still does not, data source and data member are set, the DataSource= DataSet1,
DataMember = tableName. Does it need more settings so the GridView works and shows the data?
It shows the ColumnNames, but ZERO Data.
Thanks for help.
|
|
|
|
|
Hi
When I try to set the particular rows height, it has not changed the height...So I cant identify my mistake...Any Help Please...
My Code..
DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None
DataGridView1.AllowUserToResizeRows = False
DataGridView1.Rows(2).Height = 75
Thanks for the guidences...
Thanks By
PARAMU
|
|
|
|
|
I think that your problem might be caused by where you apply your code.
I have just done a little test project and I tried putting your code in the Form's Constructor. Like you it had no effect.
I then moved it into the Form's Load method, after the DataGridView had been filled, and it worked as required.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hello,everyone! I have a treeview with checkboxes, I use "AfterCheck" event and "NodeMouseClick" event and now the treenode could change color and link to tabpages. What I question is , if a treenode didn't be checked, when I clicked the checkbox, the "NodeMouseClick" event also actived, one tabpage was selected;But I wanted that, when I clicked the checkbox, it just make the node be checked, I should clicked the node again to make tabpage display.
What should I do with treeview's event?PLZ give me some suggestions! Thx!
|
|
|
|
|
Why don't you put code in the start of the NodeMouseClick handler to check if the clicked node is checked or not?? Seems pretty simple to me...
|
|
|
|
|
Hello,Dave! I have put code like "if e.node.checked = true" in the start of the NodeMouseClick Event, but it also link to tappage. I found that I should use AfterSelect Event in MSDN.How silly I am...
|
|
|
|
|
Is it possible via VB programming to convert a word document to a pdf format? If so what is the best way and if not, how can this be done?
|
|
|
|
|
Get yourself either a PDF print driver or a PDF library such as iTextSharp[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Get yourself a PDF print driver or a copy of iTextSharp[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
As mentioned, the easiest way is to use a print driver and print the document to the PDF printer. I use doPDF[^] because it's easy, free and works great.
You can essentially print anything to a PDF file, whether it's from Word or something else.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I am attempting to write a multithreaded application.
The idea is to have a scripted exe run that takes a list of devices, strips out one device and its information into an array, creates a new object of a class. which contains a backgroundworker that contains a telnet object, to telnet to said device and perform simple work (just login at this time). I have 100 device I am doing this for.
So far, everything looks like it works. All 100 devices have a new class object and bgw worker created for them. My problem lies in how to determine when those have completed their work. This is a problem because the rest of the exe needs to process the results of my simple work but can only be done after all have completed.
How can I tell when the work is done? I was thinking about writing something into the RunWorkerCompleted event that tallys but that seems like not the best idea.
-Steve
|
|
|
|
|
So, if all of your work is being done in these worker threads, then your main application just becomes a thread manager. Right? (lets take that as true)
1) The thread manager keeps an array of status; one slot for each thread dispatched. (running/WorkDone)
2) Each thread should throw an event which represents "WorkDone"; the thread manager will
listen for this event and update the corresponding array slot.
3) When all threads have been dispatched and begin their work, the thread manager just loops around and sleeps periodically checking if all status array slots have a "WorkDone" status; when that occurs you can continue with you process.
Maybe extend you status array to have a start time so that you can determine if a thread is taking too long, you can take corrective action.
Just a thought.
Good luck.
|
|
|
|
|
So, if all of your work is being done in these worker threads, then your main application just becomes a thread manager. Right? (lets take that as true)
Yes
2) Each thread should throw an event which represents "WorkDone"; the thread manager will
listen for this event and update the corresponding array slot.
How can I make the thread throw a custom event? Conversly, how do I make the thread manager listen?
|
|
|
|
|
OK so I attempted it and I think I ran into an issue with scope.
In the worker thread, I created an event
Public Event IamDone(ByVal sender As Object, ByVal IP As String)
I call that event in the RunWorkerCompleted sub
RaiseEvent IamDone(Me, "111")
And now I am trippng up on how to create the handler in my thread manager. I assumed it would be
AddHandler myworkerthreadclass.IamDone, Addressof myworkerthreadclass.IamDone
but that doenst work
|
|
|
|
|
Why don't use just use the RunWorkerCompleted event, instead of creating a new event to raise? In RunWorkerCompleted you should be able to get the key to the device, and use that to update your status collection.
Or if you are on .NET 4.0 you can use one of the parallel collection to handle this much cleaner.
|
|
|
|
|
Hi,
1.
Yes, you want the RunWorkerCompleted event handler to do something your main thread can notice. Lots of things are possible, here is one example:
have a global variable that is initialized to the number of jobs, and gets decremented (see Interlocked.Decrement) by each RunWorkerCompleted handler, which on top of that, by checking for zero, raises a signal (see e.g. ManualResetEvent)
2.
It is a bad idea to launch many BackGroundWorkers, as that would be too expensive. The better approach would be to have:
- a small number of BackGroundWorkers (say two times the number of cores your system has, Environment.ProcessorCount);
- a queue of jobs, filled by the main thread, and queried by those BackGroundWorkers (use a lock!);
- and probably a queue of results, filled by those BackGroundWorkers (use another lock), and emptied by the main thread when it gets its "all done" signal.
|
|
|
|
|
OK so I attempted it and I think I ran into an issue with scope.
In the worker thread, I created an event
Public Event IamDone(ByVal sender As Object, ByVal IP As String)
I call that event in the RunWorkerCompleted sub
RaiseEvent IamDone(Me, "111")
And now I am trippng up on how to create the handler in my thread manager. I assumed it would be
AddHandler myworkerthreadclass.IamDone, Addressof myworkerthreadclass.IamDone
but that doesn't work
|
|
|
|
|
svanwass wrote: that doesn't work
|
|
|
|
|
|
people here are unlikely to download anything just to maybe understand a question; what you should do is explain the symptoms ("doesn't work" tells us nothing) and tell how it differs from your expectations, then ask a specific question and/or show a relevant code snippet.
|
|
|
|
|
My apologies.
Main Form
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim passing(0, 3) As String
passing(0, 0) = "10.1.1.1"
passing(0, 1) = "10.1.1.2"
passing(0, 2) = "10.1.1.3"
passing(0, 3) = "10.1.1.4"
Dim myworker As New Foo(passing)
End Sub
Private Sub IHeardThat() Handles Foo.IamDone
'this does NOT work
End Sub
End Class
My Foo class
Imports System.ComponentModel
Imports System.IO
Imports System.Threading
Public Class Foo
Public WithEvents backgroundWorker1 As System.ComponentModel.BackgroundWorker
Public Event IamDone(ByVal sender As Object, ByVal IP As String)
Dim devicelist(,) As String
Dim txtFile
Public Sub New(ByVal Value As String(,))
devicelist = Value
backgroundWorker1 = New BackgroundWorker
backgroundWorker1.WorkerReportsProgress = True
backgroundWorker1.RunWorkerAsync(devicelist)
End Sub
Private Sub backgroundWorker1_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs) Handles backgroundWorker1.DoWork
' Get the BackgroundWorker object that raised this event.
Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)
Dim myargs As String(,) = e.Argument
End Sub
Private Sub backgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) Handles backgroundWorker1.RunWorkerCompleted
RaiseEvent IamDone(Me, "Done")
End If
End Sub
End Class
So that's basically it. I attempted to write a sub that would handle the custom event but the form class doesnt see the foo class event.
Does that make sense?
|
|
|
|
|
does that compile at all?
svanwass wrote: Private Sub IHeardThat() Handles Foo.IamDone
The IamDone event is not static/shared, how can this work?
Dim myworker As New Foo(passing)
AddHandler myworker.IamDone, AddressOf IHeardThat
does work but is not OK as the handler is added while the BGW is alrady running, so there is a race condition.
possible solutions:
1. pass the delegate to the Foo constructor, so it can add the handler on time;
2. don't start the BGW from the Foo constructor, add a method the caller should call after having set the handler.
General advice:
1. consider making Foo inherit from BGW.
2. start every VB file with "option strict on"
3. tell Visual not to launch the app as long as there are compile errors
4. tell Visual to treat all warnings as errors
(2+3+4 will be a PITA at first, but it will soon teach you to write correct code)
|
|
|
|
|
I think the best way would be using a waithandle that signals when done. If you combine the waithandles for all processes, you can use the WaitHandle.WaitAll Method.
See this MSDN article for an example
|
|
|
|
|
Save the thread class instances that you create into an array or IList<thread>. Once you have started all of your threads, you can loop through the array or list checking either the State or IsAlive property of each thread until all indicate that they are finished.
This way, you don't have to block your main thread while waiting for the other threads to finish. Your main thread can continue working and just check periodically to see if all worker threads have finished.
Kevin Rucker, Application Programmer
QSS Group, Inc.
United States Coast Guard OSC
Kevin.D.Rucker@uscg.mil
"Programming is an art form that fights back." -- Chad Hower
|
|
|
|
|
Seems like I have a lot to learn about the proper handeling of threads. Would any of you have a recommendation on the topic but in relations to c#? I dislike VB...
|
|
|
|