|
Hrmmm I should chuck my 2c in here.
Sometimes (probably due to a less than ideal architecture) you may find a whole bunch of events in your queue. The correct behaviour here is to process the events. You may choose to fast-discard keypresses and clicks - but the decision to flush the queue may cause your application to lose critical information. You could lose network connectivity change notifications, system shutdown notifications...
Particularily if you are intending to have your application run on Vista - which is very very quick to detect applications not pumping their message queue, and very quick to suggest they are hanging and should be closed.
So I don't think it was "overly simplistic and incorrect". It was good advice, on par with "do not call GC.Collect()". Sure - you could think up a scenario where it might be useful - but in 99% of cases you should just do it right.
If you need to flush your message queue then use PInvoke to call the API function. If the framework supports this it will be in the Application or Form class. It probably doesnt, because its bad practice. HTH
|
|
|
|
|
All arguments aside, here's an odd behavior: Application.DoEvents() basically does the flush for me.
If I do this:
myForm.Enabled = false;
COMServerObject foo = new COMServerObject();
Application.DoEvents();
myForm.Enabled = true;
Then the queued clicks on the titlebar/closebox/minimize box, etc, do NOT get received by my app. If I reverse the order of the last two statement (enable the form, then call DoEvents()), then the messages DO get received by my app. Weird.
Noted just for interest. Not advocating this as a method to flush events.
|
|
|
|
|
Hi friends,
I have below salesreport table, how can I get results of max sales of sales persons in one query?
salesperson sales orderId
Michele 120 120121
Guido 230 120122
Michele 300 120123
Michele 250 120124
Franco 100 120125
Guido 500 120126
Franco 400 120127
the query result must be;
salesperson sales
Michele 300
Guido 500
Franco 400
|
|
|
|
|
This is more for the SQL forum methinks.
Also sounds very much like homework.
Anyway here is the solution (try and understand why it works rather than just copying it)
<br />
select salesperson,max(sales)<br />
from salesreport<br />
group by salesperson<br />
Regards
Guy
You always pass failure on the way to success.
modified on Friday, December 28, 2007 4:27:52 PM
|
|
|
|
|
Thanks so much.
You are right. It is a homework but only a part of my homework. I made it simple to apply my question. I am getting query from northwind databasesample. According to sales person's most sold products, I am using group by also and other things. I can't where anad how to put max to below code. The below code gives, all sales of salespersons according to product.
select employees.Firstname,employees.lastname,products.productname,
sum("order details".unitprice*quantity*(1-discount)) as Sales from ((Employees inner join orders on employees.employeeID=orders.employeeID) inner join "order details" on orders.orderID="order details".orderID) inner join products on products.productID="order details".productID
group by employees.lastname,employees.firstname,products.productname
order by employees.firstname
As you see, I don't have any aim to copy your response. I have gotten stuck in a point and I wanted help.
|
|
|
|
|
omegazafer wrote: You are right. It is a homework but only a part of my homework.
I appreciate your honesty in this.
With regards to the query - it's not the simplest of queries you have written - a suggestion: break it into it's component parts and get those parts working first.
omegazafer wrote: ((Employees inner join orders on employees.employeeID=orders.employeeID) inner join "order details" on orders.orderID="order details".orderID) inner join products on products.productID="order details".productID
looks overly complex to me(does it work?).
Regards
Guy
You always pass failure on the way to success.
|
|
|
|
|
Thans so much, your first response helped me so much because I didn't know the using of max with group by.
You can be sure, that code is working also it is the response of one question of my homework.
Now, i am dealing the other question I asked you.
Regards
Good Days
|
|
|
|
|
I want to access folders which are not in Inbox but outside my inbox, like my personal folders using c#.
I am using Outlook Object Library 11.0.
Would appreciate someones help.
|
|
|
|
|
|
Thanks for your help,
I had already visited that and tried below
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace olNS = olApp.GetNamespace("MAPI");Outlook._Folders oFolders;
oFolders = olNS.Folders;
Outlook.MAPIFolder oPublicFolder = oFolders.Item("Public Folders");
oFolders = oPublicFolder.Folders;
Outlook.MAPIFolder oAllPFolder = oFolders.Item("All Public Folders");
oFolders = oAllPFolder.Folders;
Outlook.MAPIFolder oMyFolder = oFolders.Item("My Public Folder");
Console.Write(oMyFolder.Name);
But it is not working giving an error at oFolders.Item("Public Folders");
|
|
|
|
|
Cut and paste from the page linked above.
"
Folders object -
You can use the Folders object to refer to any folder that is in the Outlook folder list. The Folders object is typically used to refer to a Microsoft Exchange folder or to any other folder that is not a default Outlook folder.
The following sample code illustrates how to refer to a public folder that is named My Public Folder. Notice that you typically start at the top-most folder and then work your way down to the folder that you have to reference. Also notice that the folder names are case-sensitive. You must exactly match the capitalization and the names as they appear in the Outlook folders list.
"
I'd double check this.
Just because we can; does not mean we should.
|
|
|
|
|
I read that but I got error before that and am yet to reach there.
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace olNS = olApp.GetNamespace("MAPI");Outlook._Folders oFolders;
oFolders = olNS.Folders;
Outlook.MAPIFolder oPublicFolder = oFolders.Item();
oFolders.Item is not defined thats what it says me.
|
|
|
|
|
Lets assume I have a folder named "SPAM".
I'd write that line like:
Outlook.MAPIFolder oPublicFolder = oFolders.Item("SPAM");
Maybe I'm not understanding you correctly....If thats the case, I'll leave it to someone else.
Just because we can; does not mean we should.
|
|
|
|
|
You are almost there!
What i mean is when we write
Outlook.MAPIFolder oPublicFolder = oFolders.Item("SPAM");
when i write oFolders and press ".", i don't see "Item", means oFolders doesn't have a definition of "Item" and it throws me error there itself. Specifing the folder name "SPAM" will be checked in the next step.
Hope you are getting me now.
Appreciate and Thanks a million to you!
|
|
|
|
|
OK, I get you now.
Try this out and see what you get for folder names or just refer to the folder by index.
<br />
Microsoft.Office.Interop.Outlook._Application olApp = new Microsoft.Office.Interop.Outlook.ApplicationClass();<br />
Microsoft.Office.Interop.Outlook._NameSpace olNS = olApp.GetNamespace("MAPI"); <br />
Microsoft.Office.Interop.Outlook._Folders oFolders;<br />
oFolders = olNS.Folders;<br />
<br />
for (int i = 0; i < oFolders.Count; i++)<br />
{<br />
Microsoft.Office.Interop.Outlook.MAPIFolder oPublicFolder = oFolders[i].;<br />
Console.Write(oPublicFolder.Name);<br />
}<br />
Just because we can; does not mean we should.
|
|
|
|
|
Thanks for that, but it gave me out of index error, but i just twisted your code somewhat and this is what i did and got the folder details i need.
Outlook.Application OApp = new Outlook.ApplicationClass();
Outlook.NameSpace ns = OApp.GetNamespace("MAPI");
Outlook.MAPIFolder inbxfld = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.MAPIFolder prsnlfldr = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Folders pfldr = ns.Folders;
Console.WriteLine(pfldr.Count);
foreach(Outlook.MAPIFolder fld in pfldr)
{
Console.WriteLine(fld.Name);
}
Thanks a million for your help and getting me out of this
Now I am going a step further!
Btw, liked your line "Just because we can; does not mean we should."
|
|
|
|
|
I am trying to create a method where if a user clicks on the checkbox of a treeview node it deletes it only if it is a childnode but does not delete it if it is a rootfolder. This is how I started. If anybody can give me a clue and show me how to make it work? Thanks.
private bool CheckBox(TreeNode tn)
{
if (tvFavorites.SelectedNode.Checked == true)
{
//tn.Nodes.Remove();
tvFavorites.SelectedNode.Remove();
}
else
{
return CheckBox(false); and here I get an error that "Best overloaded method: invalid argument.
}
}
modified on Friday, December 28, 2007 2:36:51 PM
|
|
|
|
|
A) To solve your problem, check to see if the selected node is a child node and perform your actions accordingly.
B) Your error; You are calling the function CheckBox passing the variable of type bool when its expecting type TreeNode. To solve, simple replace that line with "return false;"
Just because we can; does not mean we should.
|
|
|
|
|
private bool CheckBox(TreeNode tn) //but then I got an error here which says "not all paths return a value". So, what should I do now??
{
//if (tn.Checked == true)
if (tvFavorites.SelectedNode.Checked == false) //
{
//tn.Nodes.Remove(true);
tvFavorites.SelectedNode.Remove(); //
}
else
{
return false; // I modified my code here as per your suggestion
}
}
|
|
|
|
|
I'd recommend reading up on returning values from a function, google can help you there.
<br />
private bool CheckBox(TreeNode tn)
{<br />
if (tvFavorites.SelectedNode.Checked == false)
{<br />
tvFavorites.SelectedNode.Remove();
<br />
return true;
}<br />
else<br />
{<br />
return false;
}<br />
<br />
}
Just because we can; does not mean we should.
|
|
|
|
|
Thank You for the return true; statement. Atleast I dont get that error now. But I am trying to find out how to make the checkbox delete the childnode and not the root node.
That private bool CheckBox(TreeNode tn) does not get executed
|
|
|
|
|
Your function CheckBox(TreeNode tn) returns a type of boolean.
Are you doing anything with that return value?
In your checkbox checked event are you telling it to run CheckBox?
Is this the path your code is taking?
user clicks check box
->checkbox event triggers
-->checks to see if its a child node; if so
-->CheckBox code is run (removing the treenode) return true if successful, else false
Hope this helps you get back on track.
Edited to add:
To check if a treenode is the root node, check the Level property.
if(TreeViewNode.Level == 0)<br />
{<br />
....<br />
}<br />
else<br />
{...}
Just because we can; does not mean we should.
|
|
|
|
|
if(TreeViewNode.Level == 0)
{
tn.Nodes == true; //here i want to enter a code which will tell me that it is a root node. How should I put that code here it gives me an error "Operator == cannot be applied to bool"
}
else
{
tn.Nodes.Remove(false); //"here it gives me an error "Best overloaded method:has some invalid arguments"
}
|
|
|
|
|
Ok lets see here.
if(TreeViewNode.Level == 0)
{
//you know this is a root node(because the level is equal to zero, the first level of nodes!) so do not do anything!
}
else
{
//this is a child node so lets remove it.
}
<br />
private bool CheckBox(TreeNode tn)<br />
{<br />
if (tn.Checked == false)<br />
{<br />
if(tn.Level != 0)<br />
{<br />
tn.Remove();<br />
<br />
return true;<br />
}<br />
else<br />
{<br />
return false;<br />
}<br />
}<br />
else<br />
{<br />
return false;<br />
}<br />
}<br />
use this function like this
<br />
if(CheckBox(tvFavorites.SelectedNode) == true)<br />
MessageBox.Show("It was removed.");<br />
else<br />
MessageBox.Show("Its still there.");<br />
Good Luck.
Just because we can; does not mean we should.
|
|
|
|
|
Hi all,
I posted this on the .NET Framework board about a week ago and got no response, so I thought I'd try here.
I'm developing an application in which I bind to XmlDataProvider.Source property. If the xml file I'm binding to has an extension of .xml everything is fine. If it has some other extension the binding fails.
I posted on forums.microsoft.com and was given instruction to go to the Connect website and log this as a bug. Maybe I'm stupid, but I cannot figure out how to do that.
I'm posting the link to my post on the forums. I hope that doesn't violate any forum posting "codes of conduct".
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2538606&SiteID=1&mode=1[^]
If anyone has any advice, suggestion, or knowledge about this problem I would love to hear it.
Thanks.
Lily Bristol
|
|
|
|