|
venkyhyd wrote: I think it should be a problem if the C# DLL is launched by MFC or its been invoked independently in either case i am looking for communication between these two.
"I think it should NOT be a probelm if the C# DLL is launched by MFC or its been invoked independently in either case i am looking for communication between these two."
|
|
|
|
|
|
Hey folks,
I've been pulling my hair out on this one. I've got a data table that's created within the constructor for Form A (the child form). Now, this form is created from a button in Form B (the parent form), and can be done so multiple times simultaneously. I'm experiencing a peculiar problem where although Form A SEEMS to close fine (in the sense that it is fully destructed), the data table that was instantiated in that form wasn't disposed. I know this because I have a MessageBox.Show() within the constructor of Form A which displays some values from the data table. Each time the method is called, I'll have multiple message boxes depending on how many times I have opened Form A (regardless of how many times I've closed it!).
I've tried calling the dataTable.Dispose() method in the event handler for the closing of Form A and still this seems to do nothing.
I've no idea what's wrong .
Any help is much appreciated.
|
|
|
|
|
Duy Pham wrote: I've tried calling the dataTable.Dispose() method in the event handler for the closing of Form A and still this seems to do nothing.
Then you have some design issue. Can you show us some sample code?
|
|
|
|
|
It's a fairly bulky program so I'll just paste over the instantiation of the objects.
EventHandler code within Form B (the parent form) which constructs Form A (the child form):
else if (radioButton_Inventory.Checked)
{
WindowInventory new_WindowInventory = new WindowInventory(
sqlconnector, sqlconn, inv_container);
new_WindowInventory.Activate();
new_WindowInventory.Show();
}
Now when Form B finishes being constructed, I use the _Load form event to stick in my code which assigns values to the data table.
private void WindowSales_Load(object sender, EventArgs e)
{
// ...
DataGridPopulator.PopulateWindowGrid_Sales(
partlist_array, ref dataTable_PartListing);
}
And then upon closing of Form B, I pass in these two lines:
dataTable_PartListing.Dispose();
this.Dispose();
Hope that helps. Thanks!
|
|
|
|
|
Why do you think that the data tables aren't disposed?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Say I open form B and close it 4 times successively. On the fifth time I open the form B, the messagebox.show() method will construct 5 message boxes with the values of 5 UNIQUE instances of the datatable. Which makes sense since I constructed 5 data tables that didn't seem to dispose of itself upon the closing of Form B.
Hope that makes sense.
|
|
|
|
|
I don't understand what you mean...
In the constructor of form A you create one data table and show one message box? If you open and close form B, how does that have anything to do with the message boxes?
Perhaps you mixed up the form A and form B? What about calling them something that makes sense?
Duy Pham wrote: On the fifth time I open the form B, the messagebox.show() method will construct 5 message boxes with the values of 5 UNIQUE instances of the datatable.
It sounds like you are doing something that you don't think that you do... A single call to MessageBox.Show can not result in five message boxes.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Treat Form B as a the child form and Form A as the parent form. I know this sounds really bizzare, and I don't understand myself either, but the number of message boxes that appear form a SINGLE instantiation of form B is always equal to the number of times I opened (by open I mean instantiate a NEW form B, the child form, assuming any previously open instance of Form B had been closed).
The MessageBox.Show() lies within a EventHandler that I personally created from a _Tick event from a System.Windows.Form.Timer object.
private void updateTimer_Tick(object sender, EventArgs e)
{
//...
string msg = "";
for(int i = 0; i < dataTable_PartListing.Rows.Count; i++)
{
msg += dataTable_PartListing.Rows[i][0].ToString() + " ; " +
dataTable_PartListing.Rows[i][1].ToString() + " ; " +
dataTable_PartListing.Rows[i][2].ToString() + " ; " +
dataTable_PartListing.Rows[i][3].ToString() + "\n";
}
MessageBox.Show(msg);
updateTimer.Start();
}
In the above code, updateTimer is the System.Windows.Form.Timer object. By any chance, does leaving that timer on while trying to close the form leave the instance of the form, and thus all objects instantiated within it, still active?
Thanks
|
|
|
|
|
Hi everybody,
i have a question in my project,i need your help.
The question :when i printed a barcode label in b/s system,the System components like 'PrintDialog' and 'PrintDocument' does not work.while i used it in c/s system,it was worked.So,i want to know how to solute it.
|
|
|
|
|
open http://www.commstudio.com/ , maybe it will be usefull fur you
|
|
|
|
|
I want a control where there's three options: On (White background with check), Off (grayed background, no check) and Neutral (white background, no check). Any ideas?
modified on Thursday, September 4, 2008 1:10 PM
|
|
|
|
|
Jordanwb wrote: grayed background
.Enabled=false;
|
|
|
|
|
But then it will not respond to events. AFAIK there is not a 3 state checkbox standard in VS.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You may have to create your own control, inheriting from the checkbox control.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
There's a property that will allow your checkbox to have a tri-state. You should, in that case, check for the "CheckState" property instead of the "Checked" property.
You have
Off --> not checked
On --> Checked with "V"
In between --> Checked filled with a square.
hope this helps.
|
|
|
|
|
Thanks that's what I was looking for.
|
|
|
|
|
Use a CheckBox . Set the ThreeState property to true .
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks, that's what I was looking for.
|
|
|
|
|
Hi there, is there a C# method that will allow me to search for all the files of a specific extension and then delete them? I know there is an Exists method, but what do I pass into the method? What I have available are the path to the files and its extension.
|
|
|
|
|
System.IO.Directory.Getfiles. I can't remember all the params but one is where to search, and what to search for. If you want to search for exe's you put "*.exe"
|
|
|
|
|
You can't delete using a pattern, you need to identify each file and delete it individually. Use the directoryinfo getfiles method with a pattern filter, loop and delete each file.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi All,
I have to forms.
In my seconde form i have a button that updates the first form.
The problem is that when i click that button, the first form get updated , bud the second form desappears, then i have to click bring it back from the windows taskbar.
How can i prevent that? i want that the second form remains active.
Thanx.
|
|
|
|
|
try searching the site
"Update parent form" turned up this article which may be of use.
clickety[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How you are updating form1 from form2?
Alternatively, you can show the second form as a modal window.
|
|
|
|