|
Hi
i am working on .NET 2.0 winforms. in my form there is cancel button, in this event i am showing warning message "do u want to save the changes?". I need to show same message on when clicking on wikndow X button?
how can i do...
any sounds greatly appriciated
Ramana
|
|
|
|
|
Check with the form events, it got some events which will fire when a form ends. Somethink like closed, closing etc
|
|
|
|
|
i will write the code in closing event. but if user will clicks on X button, and on No, then how can make window re-active?
Ramana
|
|
|
|
|
There should be a "cancel" property in the event args of the closing-event. If you set this to true the closing will be - well - canceled.
|
|
|
|
|
Hi,
Form.FormClosing event is the prefered one since .NETY 2.0
set FormClosingEventArgs.Cancel true to cancel the close operation.
and maybe FormClosingEventArgs.CloseReason will be useful too.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I need to get data in treeview control from database while using multi threading.
|
|
|
|
|
... and the problem is?
I guess you've got an error while inserting items from another thread.
The sollution is to use the InvokeRequired - property of the treeview to query if you are calling from a different thread and if so using the controls Invoke -function to call a function that handles the actual insertion, here is a sample:
<br />
void FunctionCalledByThread( )<br />
{<br />
if (treeView1.InvokeRequired)<br />
treeView1.Invoke(new InsertItemsDelegate(InsertItems), );<br />
else<br />
InsertItems( )<br />
}<br />
<br />
delegate void InsertItemsDelegate( );<br />
void InsertItems( )<br />
{<br />
<br />
}<br />
|
|
|
|
|
Hello experts,
This is very frustrating, I post a message and near about 10-15 reply from me and and other code project members are their in the post.
But I was unable to find that post...? is any body delete complete post...?
And also when I goto my account and see the message posted (155). When I click on this only top 40 message displayed, When I click on next and previous button the page index and counting of post is also changed but same posts are displayed again and again...?
Where are my other posts...?
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
It was clearly posted in the lounge that posts on Sunday were likely to get lost. They did. The site has been updated, there are some issues, they are being worked on.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: It was clearly posted in the lounge that posts on Sunday were likely to get lost. They did.
But look at the implication in his post:
Pankaj - Joshi wrote: And also when I goto my account and see the message posted (155). When I click on this only top 40 message displayed.
He posted 115 messages on Sunday!!
|
|
|
|
|
Hi,
I want to group rows of excel using c#.
how can i do it???
Pls suggest me..
|
|
|
|
|
ApplicationClass excelApplication;
Workbook excelWorkBook;
Worksheet excelWorkSheet;
excelApplication = new ApplicationClass(); excelWorkBook = excelApplication.Workbooks.Add(Type.Missing); excelWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet) excelWorkBook.ActiveSheet; excelWorkSheet.get_Range(excelWorkSheet.Cells[1,1],excelWorkSheet.Cells[1,2]).Merge(Type.Missing); excelWorkSheet.Cells[1,1] = "Merged Text"; excelWorkSheet.get_Range("A1","A1").Interior.ColorIndex = 37; excelWorkSheet.get_Range("A1","A1").Interior.Pattern = XlPattern.xlPatternSolid; excelWorkSheet.get_Range("A1","A1").Font.Bold = true; excelWorkBook.SaveAs("C:\\NewExcel_CSharp.xls",Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing); excelApplication.Quit();
and for that you need
Microsoft.Office.Interop.Excel.dll
|
|
|
|
|
<code>
ApplicationClass excelApplication;
Workbook excelWorkBook;
Worksheet excelWorkSheet;
excelApplication = new ApplicationClass();
excelWorkBook = excelApplication.Workbooks.Add(Type.Missing);
excelWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet) excelWorkBook.ActiveSheet;
excelWorkSheet.get_Range(excelWorkSheet.Cells[1,1],excelWorkSheet.Cells[1,2]).Merge(Type.Missing);
excelWorkSheet.Cells[1,1] = "Merged Text";
excelWorkSheet.get_Range("A1","A1").Interior.ColorIndex = 37;
excelWorkSheet.get_Range("A1","A1").Interior.Pattern = XlPattern.xlPatternSolid;
excelWorkSheet.get_Range("A1","A1").Font.Bold = true;
excelWorkBook.SaveAs("C:\\NewExcel_CSharp.xls",Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
excelApplication.Quit();
</code>
and for that you need
Microsoft.Office.Interop.Excel.dll
|
|
|
|
|
hi abhijit,
Thanx for your response.But I am sorry that your code is not resolving my
problem.All i want is to group/ungroup rows(collapse/expand) using c#.
ex: In excel select some rows and go to Data->Group and Outline and select
group.It will collapse rows with mark '+'.This i want through c# code.
|
|
|
|
|
Hello everyone,
I am trying to get the IP Address of the client so the application can hook itself up to it. I am using the following code:
private void MyApplicationForm_Load(object sender, EventArgs e)
{
string strIP = null;
IPHostEntry HosyEntry = Dns.GetHostEntry((Dns.GetHostName()));
if (HosyEntry.AddressList.Length > 0)
{
foreach (IPAddress ip in HosyEntry.AddressList)
{
strIP = ip.ToString();
cmbInterfaces.Items.Add(strIP);
}
}
}
When I run the application on my PC which is connected via a cable to a routher I only get on IP address which is the internal IP address. But when I run the Application on my laptop which is using Wireless Connection to the same routher I get list of few IP addresses. Can someone tell me why this is the case and how can I make sure I only the IP address that my laptop is set to rather than the list of the IP addresses.
Thank you very much and have a great day.
|
|
|
|
|
Hi!
I think you have a basic misconception here:
Any given PC doesn't have "the one IP address", it all depends on the network connections you have.
Worst case: No network at all, so the PC doesn't have an IP address at all.
In all the other cases, each network interface can (and usually will) have a different IP address. Try opening a command shell and executing "ipconfig /all", you'll see the settings and IP addresses for all the network interfaces.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
hi
I don't know how I can give address of specify process
can you help me
regard
|
|
|
|
|
I am creating a simple program that reads and writes files to a database. I have SequetialAccess for reading the data down, it works great, and is very very efficient.
The problem I have is with writing to the database. I can only write the file BLOB in one big, very slow chunk. I want to be able to create a buffer and write in buffered intervals.
Any suggestions.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hi i trying to search for values in .txt file and return the existings lines
But how can i trim down the string[] Chunk to -3 letters??
for example:
.txt file look like this
#
k441122
blabla
blabla
blabla
blabla
if i search for k441 than return the k441122 with all the existings lines?
i have tryade Chunk.Substring(0 , 4)
Any idea??
My code look like this:
private bool ReadChunk(StreamReader sr, out string[] Chunk, string MatchData)
{
Chunk = new string[9];
bool FoundMatch = false;
for (int i = 0; i < 9; i++)
{
try
{
Chunk[i] = sr.ReadLine();
if (i == 1 && Chunk[i] == MatchData)
{
FoundMatch = true;
}
}
catch (Exception ex)
{
FoundMatch = false;
}
}
return FoundMatch;
}
Big Tnx!!
|
|
|
|
|
Use Regex.
if (Regex.IsMatch(szStringToSearch, szPatternToFind, RegexOptions.IgnoreCase))<br />
{<br />
MessageBox.Show("Success");<br />
}
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hey guys,
I need your help with 2 things on a DataGridView in VS2005.
1) I need a cell to have 1 row in it underlined, e.g:
<underlined> hello
world
2) I need to have a border between 2 lines in the DataGridView highlighted (bolded, colored etc)
Thanks!
|
|
|
|
|
I am making a project that is due soon and one of the last things i need to do is set frmSearch as a child of the parent form frmMain.
Here is my problem
I have frmMain, when it opens I click on a button that opens frmEmployeeInfo. This is a child form and works well. On this frmEmployeeInfo there is a button that takes me to the form frmSearch. I am having problems setting frmSearch as a child of frmMain. Is there a way to do this.
I have tried everything. I tried creating a method in frmMain and calling it in frmEmployeeInfo (supposed to open the frmSearch and set it as child), i tired a lot of other stuff, and I am getting down to the wire.
Please help
And I thank you in advance. I will be on line refreshing this page every couple of mins if you need more explination.
Thanks again
Kyle
|
|
|
|
|
Set the Owner or Parent of the new child form to be the owner/parent of the form that is creating it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Im a little confused. What do you mean?
Kyle Maldonado
|
|
|
|
|
Each windows from has a method called Show and ShowDialog. Each of these methods has an overload that accepts an IWin32Window). The MSDN documentation states that the IWin32Window is any "object that implements System.Windows.Forms.IWin32Window and reprepsents a top-level window that will own this form.
If you were to do frmSearch.ShowDialog(someFormName), I think this would accomplish what you are after.
|
|
|
|