|
Before asking this kind of (stupid) question you could try it yourself. If you had, you would realize that your suggestion is not even possible to compile, hence the "new" keyword (even if you do not "fully understand" it) is necessary.
Internet - the worlds biggest dictionary
|
|
|
|
|
Wow!
You really must have a bad day!
Try it with joga!
But dont't mind, weekend is coming!
|
|
|
|
|
Thanks buddy. Obviously the point of my question was to understand how the new keyword works in general, not just to get my code working in this particular instance. I searched for info on the worlds biggest 'dictionary,' and the way the new keyword is explained is the same almost everywhere. I didn't quite get it, so I was looking for a different perspective. Also, your mom.
|
|
|
|
|
Sorry, I was being a bit more grumpy than needed. My mom
Internet - the worlds biggest dictionary
|
|
|
|
|
Loophole wrote: And if I do need to use the new keyword there, does it just leave the old object hanging out there to be cleaned up by the CLR later?
Yes, and if you do this and the object has a Dispose method, you should call that first.
Loophole wrote: command = OdbcCommand(newStatement, connection);
You obviously still need the 'new' keyword in this instance.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
i have two forms ie, Form1 and Form2. Form1 contains a Button Control.
i have write code in Button of Form1 to Open Form2. Problem is that when each time i click button of Form1 it Opens new Form2. How to Control that? if Form2 is open it should not be open again.
privete ..Button1_Click(....)
{
Form2 objFrm=new Form2()
objFrm.Show()
//objFrm.ShowDialog();
}
Sanjit.rajbanshi@wlinktech.com
|
|
|
|
|
You can try o check if the Form2.visible = false and only then show the Form2, else do nothing
|
|
|
|
|
Hello,
One posibility would be:
Hold the instance of the Form2 class lokal in Form1.
private Form2 objFrm2;
in your Button Click event:
private void button1_Click(object sender, System.EventArgs e)
{
if(objFrm2==null)
{
objFrm2 = new Form2();
objFrm2.Closed+=new EventHandler(objFrm2_Closed);
objFrm2.Show();
}
else
{
objFrm2.BringToFront();
}
}
private void objFrm2_Closed(object sender, EventArgs e)
{
objFrm2 = null;
}
Hope that helps!
All the best,
Martin
|
|
|
|
|
Thanks! it is working
Sanjit.rajbanshi@wlinktech.com
|
|
|
|
|
|
You could also disable the button for as long as form2 is open.
Luc Pattyn
|
|
|
|
|
Hi,
We are retrieving records using Select Query from SQL Server Database tables. We want to create a html page and write the retrieved records using StreamWriter. How can we do that i.e. by using StreamWriter?
suggetions appreciated.
|
|
|
|
|
You asked this already the other day. I guess XML and CSS didn't work out for you.
We already showed you how to write with StreamWriter though. What is it you still don't understand about it?
|
|
|
|
|
the thing is just that i don't understand how to display the records (that are returned from a query) on any medium, be it XML or StreamWriter
|
|
|
|
|
If you tell us the medium that you are using to handle the results for your SQL query it could help us to guide you. Are you using DataSet and/or DataTable objects?
|
|
|
|
|
i'm using DataTable to hold the retrieved records.
|
|
|
|
|
From a DataTable object you can simply call the WriteXml(string filename) method to write to an XML file.
To write with a StreamWriter try:
using (StreamWriter sw = new StreamWriter(filename))
{
try
{
foreach (DataRow row in myDataTable)
{
sw.WriteLine(row["columnName1"]);
sw.WriteLine(row["columnName2"]);
sw.WriteLine("<body>");
sw.WriteLine("<otherformatting>" + row["columnName1"]);
sw.WriteLine("</body>")
}
}
catch (Exception er)
{
}
finally
{
sw.Close();
}
}
-- modified at 5:02 Friday 26th January, 2007
|
|
|
|
|
thanks for the suggestion.
i'll try it and if it still doesn't work for me i'll post another query for u to answer
|
|
|
|
|
Hi all. In Gridview, we can check whether grid contains rows or not by
Gridview1.Rows.Count .. Please tell me how to check against listbox.. Basically, I want to check whether listbox contains values or not. if it contains no value, then a message is displayed like NO RECORD FOUND. please help me in this regard.
|
|
|
|
|
Hello,
The ListBox class has a Property Items, which contains all the infos you need!
listBox1.Items.Contains(object); //search for an item
listBox1.Items.Count; //number of items
All the best,
Martin
|
|
|
|
|
I've written a program to access Text File , and filtered to a Data Table, then to Data View and Data Grid , and use GridStyle to display read only fields , but when I add a comments field in the GridStyle as a edited column , anytime I click the Data Grid field then push button to refresh , the marked read only fields show above the Data Grid , can anyone teach me how to correct this , thanks very much !
|
|
|
|
|
Oh Brainy Ones!
final_list=Convert.ToString(attribute_list.LastIndexOf(",",1,attribute_list.Length));<br />
All it returns is -1. If I change the value of the third argument of the function to 1,it returns -1.
The above code gives an exception
Argument Out of Range exception. Count must be positive and count must refer to a location within the string/array/collection.
i.e. count is the third argument
|
|
|
|
|
Well, it's hard to comment without knowing what is in attribute_list. It seems it doesn't contain a ,, and so the index is -1 ( indicating failure ).
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
i've checked the string and it does contain a ",", but the third argument of the LastIndexOf() still gives the exception.
Count must be positive and count must refer to a location within the string/array/collection.
the only time it doesn't give the exception is when v give 1 in its third argument.
any other suggestions??
|
|
|
|
|
First suggestion : use ToString instead of Convert.ToString
Second suggestion: change the 1 to 0, strings are 0 based. This means when you start with 1, the Length property is 1 bigger than what is allowable, hence the exception.
Third suggestion: if you want to search the entire string, don't specify a start and length at all, you can just give it the ',', and it will search the entire string.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|