1
Answer

Minimize on close, but only from X

Photo of jakar

jakar

20y
2.1k
1
Hi, I want to prevent my main Form from closing when the X in the upper right is pressed. I am handling the Closing event, and can change the CancelEventArgs.Cancel to true. The problem is I don't want to prevent the user from closing the Form using the Exit option in the menu. The Exit menu just calls this.Close() at the moment. Should the Exit menu call something else? Or is there a way to differenciate who initiated the call? During either operation, the "sender" to the Closing event is the Form. I guess I could just set a bool value on the Form that tells me not to exit the application, then set the value to say exit the application during the menu Exit, just before calling this.Close(). Is there a cleaner way of doing this?

Answers (1)

0
Photo of Ankit Sharma
NA 8.8k 141k 7y
Hi Anoop,
 
Please try this SQL and let me know if it works for you
 
  1. declare @storeid bigint    
  2. set @storeid=19    
  3. select  I.NameOfStores, I.ReferenceNo, SUM(Inwards.InwardQty) InwardQty,  SUM(ISNULL(Issued.IssuedQty,0)) IssuedQty, SUM((ISNULL(Inwards.InwardQty,0)-ISNULL(Issued.IssuedQty,0)))as Balance    
  4. from InventoryInwards as I     
  5. LEFT JOIN    
  6.         (select ReferenceNo,  nameofStores, ISNULL(Sum(ISNULL(Qty,0)),0) as InwardQty    
  7.         from InventoryInwards where StoreID=@storeid  
  8.         group By NameOfStores, ReferenceNo, Unit) as Inwards ON I.NameOfStores = Inwards.NameOfStores    
  9.         and i.ReferenceNo=Inwards.ReferenceNo  
  10.          
  11. left JOIN    
  12.         (select   nameofStores, ISNULL(Sum(ISNULL(Qty,0)),0) as IssuedQty    
  13.         from InventoryIssued where StoreID=@storeid    
  14.         group By NameOfStores, ReferenceNo, unit) as Issued on I.NameOfStores= Issued.NameOfStores    
  15.         
  16.           
  17.     
  18. where i.StoreID = @storeid    
  19. group by I.NameOfStores, I.ReferenceNo, I.Unit   
Accepted
0
Photo of Anoop Bansal
NA 58 2.2k 7y
Thanks Ankit... that was I missing out.