|
It doesn't put the braces in for two reasons:
1. C# is not line based, as VB. A new line doesn't mean that the header declaration is complete.
2. In some cases the parenthesis after the parameters is not the last part of the declaration. It would be confusing if the editor would fource the braces in when there still is more things that you can put there.
Example: This is perfectly valid code in C# (if perhaps badly structured):
public
class
A
{
public
A
(
)
:
base
(
)
{
}
}
Notice the call to the base (object class) constructor call after the parameter paranthesis.
---
b { font-weight: normal; }
|
|
|
|
|
NewbieDude wrote: is this how C# works?
It is how the IDE works.
NewbieDude wrote: I assumed it would put the braces in automatically?
Is it really such a big deal to type two braces?
I tried Visual Assist, which does that sort of thing for you, but I got rid of it because it was just plain annoying.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
I don't mind typing braces in but I just had to ask! I am really starting to enjoy C# now, its quite an adjustment from VB6 & VB.net
|
|
|
|
|
SCNR: Thats because you are PROGRAMMING now and not SCRIPTING anymore...
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
|
In C# using excel.Application to output report.But when error happend, the excel can't close. I must write some coding for close excel.When Close excel,a save as dialog been showed.I want to not save the book,I want to close the excel only.How to do it? Can you give me a sample?
|
|
|
|
|
Perhaps if you undo actions back to the starting state, you can close Excel without getting the confirmation.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
u can do that by setting the variable of Excel.Workbook to true.
i.e. if u have an object of Excel.Workbook called WB
then just write WB.Saved = true; before closing the application or excel application.
Hope that works for u
Regards,
Pramod
|
|
|
|
|
I post the message in message boards, after this I try to use worksheet.saveas method that save to my driver, then close the worksheet.
app.Workbooks[1].SaveAs(@"c:\temp.xls", Missing.Value, Missing.Value,
Missing.Value,Missing.Value,Missing.Value,
Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
Missing.Value,Missing.Value, Missing.Value, Missing.Value, Missing.Value);
app.Application.Workbooks.Close();
app.Application.Quit();
app.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject (app);
the work sheet been closed, but the process still in task manager until my application been closed. Why?
so ,I more wrote code
Process[] procs = Process.GetProcessesByName("EXCEL");
foreach (Process proc in procs)
{
if (!proc.CloseMainWindow())
{
proc.Kill();
}
}
GC.Collect();
app = null;
At last, the excel porcess been disappeared in task manager.
|
|
|
|
|
Take a look at application.DisplayAlerts the .saved can be tricky, and there are situations where the excel doc will toggle it without you explicitly setting it. .Displayalerts suppresses ALL warnings from the excel document, but it definetely gets rid of the "do you want to save" issue.
|
|
|
|
|
Hi All,
I am having a problem with passing data from one form to another.
I have a Main Form, which everything is viewed in, however, sometimes a pop-up may be used for quick items (ie quick add a client).
I have been able to get data to pass forward (Ie parent to pop-up) and reverse (pop-up to parent - using the onclose event) however I cant use a onclose event for a pop-up that is from another pop-up.
For example:
Main Form --> Search Client (doesnt Exist) --> Add Client
I close the search form and need to pass the information in Add Client to the Main Form.
Any help would be appreciated.
Cheers All
|
|
|
|
|
bootn wrote: I have been able to get data to pass forward (Ie parent to pop-up) and reverse (pop-up to parent - using the onclose event) however I cant use a onclose event for a pop-up that is from another pop-up.
Then you need to pass to the popup of the popup the same information that the popup received from the Main Form. In other words, what information are you using in the popup to return the information back to the main form? (The answer to that will give you the information you need to do the same from the popup of a popup)
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Is there any way of Directly accessing a control on the parent form from the 3rd level pop-up (ie a text box)
|
|
|
|
|
bootn wrote: Is there any way of Directly accessing a control on the parent form from the 3rd level pop-up (ie a text box)
This way lies maddness....
One form really ought not to know about another form. (There are some exceptions, like a series of forms that make up a wizard - but even then it probably isn't the best idea)
You should be passing information around using events to notify other forms that data has changed, the other form then has the option to update itself based on those events. You can read this article on passing values between forms[^] to see how to use events to pass information between forms. By doing this you decouple forms from one another which leaves you open to easier changes in the future.
Also, the idea of a third-level popup should be ignored unless the previous popups were modal dialogs. The reason for this is that the user won't see it that way. Popping up forms that can be independently dismissed provides no meaningful heirarchy to the user. When you use modal dialogs you have to dismiss the most recent to get to the previous dialog and so on. This does provide a meaningful heirarchy. So, in your situations all forms are children to the main form.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Thanx alot for the help, I have managed to get it to do it the long way (pass throught the "2nd" pop-up
Cheers mate
|
|
|
|
|
Hey, running an app that has to enumerate thru a treeView and create a connection to each node(or pc).
because our network is so large i need to give the users the ablity to close the connection/exit the application prior to the connection closing itself.
The problem i'm running into is that i'm running the treeView enumeration on a separate thread (due to the time/system expense and it was continually locking up the interface) and I can't elegantly kill the thread.
I intermittently receive "Thread was being aborted" when trying to stop/abort the thread. I've searched around and all i can find is related to web redirects, which isn't my problem. I've attempted to follow the msdn directives regarding this but haven't had any luck(thread.join).
I've also tried to look into closing the connection as that would allow the thread to close properly, but i can't find anything on how to close a managementScope object. (I may have not looked hard enought on this part )
I could use any help that you may offer.
string Beautiful;
Beautiful = "ignorant";
label1.Text = "The world is full of " + Beautiful +" people.";
Why is common sense such an un-common comodity?
|
|
|
|
|
wetrivrrat wrote: The problem i'm running into is that i'm running the treeView enumeration on a separate thread (due to the time/system expense and it was continually locking up the interface) and I can't elegantly kill the thread.
I intermittently receive "Thread was being aborted" when trying to stop/abort the thread.
As long as your applcation is not left in an unusable state, IMO just catching that should be ok. Another idea is to use a bool (perhaps static) value somewhere that u can set to exit the thread. You can also look at some other classes in the Threading namespace, but normally a simple check is enough.
xacc.ide-0.1.2 'Milestone' - includes full source Now supporting 24 languages including F#, FreePascal/Delphi and VB.NET
|
|
|
|
|
Thanks for the response,
i've included a small section of the code that deals with the thread abort calls. I guess a bit more description into what i'm receiving may help...
its not so much the initial error, as i could find a creative way to handle it, but its that i'm receiving the error multiple times. So even if i catch the error i'll still have to deal with multiple instances of the same issue.
After watching the system processes I can see that instead of increasing by only one thread, or maybe even two for that matter i'm actually increasing by 4 sometimes 7 while the app is enumerating thru the connection nodes...
this is only a concern because i'm receiving sometimes 3 or more "Thread was being aborted" messages, so i wanted to see why.
I've also tried to capture that message by using a try,catch, but haven't yet found a way to do it. not sure if that has anything to do with the unhandled exception nature of this message or not, but its just odd....
anyhow i'm sure i'm only confusing the situation more by explaining...
case 3:
result = MessageBox.Show("~","Please Verify", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
try
{
if(result == DialogResult.Yes)
{
menuItem42.Visible=true;
menuItem45.Visible=false;
if (PcTree.IsAlive == true)
{
PcTree.Abort();
PcTree.Join();
label1.ResetText();
progressBar1.Value = progressBar1.Minimum;
}
}
}
catch (ThreadAbortException abort)
{MessageBox.Show(abort.Message + abort.StackTrace);}
break;
string Beautiful;
Beautiful = "ignorant";
label1.Text = "The world is full of " + Beautiful +" people.";
Why is common sense such an un-common comodity?
|
|
|
|
|
okay, okay, it looks like i'm getting closer to the resolution....
it appears that either by accident( ) or by the objects design, i am actually creating at least 2 other threads at the same instance when i am starting the enumeration loop, so when i go to close it, the first actually closes nicely, its the others that are left in the loop that start #itching ....
So, i'm off to see the wizard, the wonderful wizard of Threads to see what I have to do get home. Now, if i could only find my way....
string Beautiful;
Beautiful = "ignorant";
label1.Text = "The world is full of " + Beautiful +" people.";
Why is common sense such an un-common comodity?
|
|
|
|
|
Hi All,
I am facing a very annoying problem. In my Form, I have a dataGridView control which is being loaded with data at the time when Form loads. After that, with user's interation, some place, new rows are added to the Table of that DataGridView but unfortunately the The DataGridView is not showing the new rows. If I close the application and run the application again, then next time the datagridview shows the new rows. I tried with this following statement just after adding the new row.
myTableAdapter.Fill(myDataSet.myTable);
Still no respose is seen in the datagridview ( as well as the the dataSet)
Please help !!!...
Regards
Emran
|
|
|
|
|
to be noted
r u call the function which fills the grid in the page load in a '!IsPostBack' condition
also r u callin the same function again after updation of rows
sathy
|
|
|
|
|
Hi Sathy,
Thanks for replying me. I got hope that someone will help.
Ok, I am working on Windows Form. I have a Combo Box which is bounded with a dataSource named "MyDataBindingSource" and I have a DataGrid named "MyDataGrid" which is also bounded with the same dataSource "MyDataBindingSource" . Now, In order to Insert new Row or Delete existing row I use an external button which manually open database connection, Insert or Delete Rows and then close the Connection. After performing this task, I am having hard time to Update my that Combo Box and that DataGrid with the new data. I am trying so many approoach like, myTableAdapter.fill(myDataSet.MyTable) but nothing is being updated. Looks like all data which is available in the main datasource is staying in Cache and When I restart the application, then i see the new data available both in combo box and dataGrid. So, that means, My user will have to restart the application everytime they insert or delete rows and if they want to see the effect.
Please help me, I think i am missing some snippet of code which can solve this issue but as I am new, I dont know.
I appreciate your time, Thanks and regards
Emran.
|
|
|
|
|
MyDataGrid.Refresh() sounds like it might solve your issue. Without knowing more about what kind of form(web, windows, etc) or how you're modifying the underlying datatable(or where the datatable even is) I can't really give you more specific advice.
|
|
|
|
|
Hi Drew McGhie,
Thanks for responding to my request.
I have tried with myDataGrid.Refresh(), but still i dont see any updates. In order to specify my problem more accurately, I am quoting the reply here That I replid to Sathy.
Ok, I am working on Windows Form. I have a Combo Box which is bounded with a dataSource named "MyDataBindingSource" and I have a DataGrid named "MyDataGrid" which is also bounded with the same dataSource "MyDataBindingSource" . Now, In order to Insert new Row or Delete existing row I use an external button which manually open database connection, Insert or Delete Rows and then close the Connection. After performing this task, I am having hard time to Update my that Combo Box and that DataGrid with the new data. I am trying so many approoach like, myTableAdapter.fill(myDataSet.MyTable) but nothing is being updated. Looks like all data which is available in the main datasource is staying in Cache and When I restart the application, then i see the new data available both in combo box and dataGrid. So, that means, My user will have to restart the application everytime they insert or delete rows and if they want to see the effect.
Please help me, I think i am missing some snippet of code which can solve this issue but as I am new, I dont know.
I appreciate your time, Thanks and regards
Emran.
|
|
|
|
|
The question then is what you're binding to. If you open the connection, query the database and put the results in a local dataset, and use that as your binding source, you won't see any updates unless you refresh your local dataset from the remote dataset from the connection. You need to either A) refresh your local dataset when you add stuff remotely, or B) do all adding/deletion locally and then refresh the remote dataset at an approprate time(like when a user hits a save button, or on form close).
Hope this helps
|
|
|
|
|