|
This error is quite general, and ill descriptive. Could you please post more code of what you are trying to do exactly?
Regards
|
|
|
|
|
|
PS.
Your question -and code which is not surrounded bu pre tags- is a bit vague. I'm taking guesses here.
You don't need to call the event handler itself -though there are ways of doing it-. You can simply extract the code into a common method:
private void b1_Click()
{
MyMthod();
}
private void MyMethod()
{
}
Was that what you were looking for?
Regards
|
|
|
|
|
Maybe the Button.PerformClick method is what you're looking for.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi all
The following is the code for tree view child node text i am accesing the child node text from another Form2 but it doesnt works when i am running the applictaion the child node is created but the name doesnt appears
TreeNode childnode = new TreeNode(objform2.textBox1.Text);
root.Nodes.Add(childnode);
SAS
|
|
|
|
|
|
Hi
Urgent Please help.
I am creating word template project. I want to access the active document in this project.
Please help me to which instance I should us to access active document.
Thanks in advance
Amit
|
|
|
|
|
i have created a website but i am facing problem to create option "remember password on same computer"
if anyone have idea or code to use the same option please send me.
thank you!!!
contact me: ashish.0619@gmail.com
|
|
|
|
|
Ashish Porwal wrote: code of remember me!!!
System.out.print("remember me!!");
|
|
|
|
|
How to write the bussiness rules in triggers i want some examples
Hi all,
vikram929
|
|
|
|
|
Hello:
I'm having a bit of trouble understanding the use of passing a collection object (in my case an ArrayList) as a ref parameter to a method that needs to add to the collection or otherwise modify the ArrayList's contents. Basically, I'm wondering which is the better, or more accepted, way to do this.
Consider the following bit of code - Both of my Test methods will modify the contents of my ArrayList and allow me to access all the values in my Main() method. However, I don't really understand which would be the better way to do it. Could someone please provide me a bit of understanding on this particular use of ref? Maybe what the pros and cons are of the two ways I do it here... why would I pick one way over the other?
Thanks!
using System;
using System.Collections;
namespace TestConsoleApplication
{
internal class TCA
{
[STAThread]
private static void Main(string[] args)
{
try
{
ArrayList List = new ArrayList();
List.Add(1);
List.Add(2);
Console.WriteLine("Passing the array:");
Test(List);
foreach (int i in List)
{
Console.WriteLine(i);
}
Console.WriteLine("\nPassing the array as a ref parameter:");
Test(ref List);
foreach (int i in List)
{
Console.WriteLine(i);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
#region Pause
Console.WriteLine();
Console.WriteLine("Done.");
Console.ReadLine();
#endregion
}
private static void Test(ArrayList list)
{
list.Add(3);
list.Add(4);
}
private static void Test(ref ArrayList list)
{
list.Add(5);
list.Add(6);
}
}
}
|
|
|
|
|
Don't use ref unless you need it.
You only need the ref keyword if you want to change the actual variable that is used to call the method, not just the contents of the variable. Here is an example of when you would need the ref keyword:
private static void CreateList(ref ArrayList list) {
list = new ArrayList();
}
However, there is almost never any real need for the ref keyword. It's mostly used in procedural programming, seldom in object oriented programming.
The method that creates a list can be written like this, which will also make it clearer:
private static ArrayList CreateList() {
return new ArrayList();
}
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
Thank you for making the use of ref more clear to me I appreciate it.
|
|
|
|
|
I want to upload some multimedia file to my website. Just like Youtube does. However, I searched google and didn't find any samples. It seems like there is a control called CSUpload Controls in .Net 2.0. But not sure whether it can load video file.
|
|
|
|
|
Hi
you mean upload any file,
I think uploading a video or any file doesnt matters,
So you can use FileStream class, you save copy any file on your server,
by also including the authancation mode.
Cheers.
|
|
|
|
|
Hi one & all
I m wirting a code for dynamic DataGrid, in that i have a column of Date. so store procedure is exactly working but in code some what mistake ,
I have written the code like this
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.DateTime");
myDataColumn.ColumnName = "CreatedOn";
myDataColumn.ReadOnly = false;
myDataTable.Columns.Add(myDataColumn);
In for loop, i have taken as
string noofre = Convert.ToString(dt.Rows[i]["CreatedOn"]);
myDataRow["CreatedOn"] = noofre;
myDataTable.Rows.Add(myDataRow);
But i m getting some problem to retrieve this.
So please kindly help me to solve this problem.
Regards,
Narendra
+91 9885179844.
Help this content to solve.
|
|
|
|
|
I'm trying to change some code found on the net so that it wil read and display the result in 9 texboxes.
The for statement works i just need to find out how use 'i' in stead of tbTargetAddress'0' so that for eatch 'i' I will use an other textsbox.
Example for the code is below...
In addition I would like to change the background color of the textbox depending from the 'if' result. I've found that set {tbResponseTime10.BackColor = Color[Red]} should do the trick but again a can't find the way to integrate this in the if statement.
Thanks,
Geert
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i<9;i ++)
{
MessageBox.Show(i.ToString());
try
{
TimeSpan span = ping.Send(tbTargetAddress0.Text, new TimeSpan(0, 0, 0,0,250));
if (span == TimeSpan.MaxValue)
tbResponseTime10.Text = "Timeout";
else
tbResponseTime10.Text = span.TotalMilliseconds.ToString("N1") + " ms";
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message, "Could not send ping command", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
|
|
|
|
|
new to this wrote: i just need to find out how use 'i' in stead of tbTargetAddress'0' so that for eatch 'i' I will use an other textsbox.
One easy way is to simply create an array of references:
TextBox[] tbTargetAddress = new TextBox[] { tbTargetAddress0, tbTargetAddress1, ... , tbTargetAddress8 };
Now you can access the textboxes using the array: tbTargetAddress[i].Text
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
Hi,
For my programming purposes i've decided to implement a class called MyRectangle.
It has the x,y,width,height variables and some other important objects that i want contained into this MyRectangle object ... (I know of the system.Drawing.Rectangle, but that's not the point. I simply want to learn how to create own objects that can be drawn into a Windows Form)
I have now a Windows Form with a single button with the Click event; when button
clicked i want to draw my own object of MyRectangle. Simple enough just to test it.
Let's say i have a method drawMyRectangle() that perhaps uses the System.Drawing.Rectangle itself.
I've been reading about the Paint()-method, PaintEventArgs e and so on.. But i just can't connect it all..
Is there someone out there who can shine some ligth ?
Thanks from Daniel
|
|
|
|
|
For a simple test, you don't have to bother about the Paint event. Just draw anything on the screen to see if you can do it. What you draw will of course not be persisted by windows, and might be erased by any window redrawing itself, but that doesn't seem to be your first concern right now.
When you want what you draw to be persisted by windows, you have to draw it using the Paint event. The Paint event is used to redraw a control, so if you want to draw something on a control, you just make sure that the code in the Paint event draws it, and call Invalidate on the control. Then the GUI will use the Paint event to redraw the control, and your code will also be used. What you draw will also be persisted, as the GUI will use your code whenever the control has to be redrawn, for example when you switch back and forth between windows.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
The link with Paint event is simple.
Suppose you have a form. Typically you can add your delegate to handle the Paint event. It will look like the following
void MainFormPaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
}
Inside this method you have to do all your custom drawings,i.e. if you want to represent graphically your MyRectangle object then you have to do it there (because the Paint event is fired when the form needs to be painted, WINDOWS is event-driven). I suggest to you to put the actual painting code of your class inside a method wich resembles the signature of
the above one, e.g.
class MyRectangle
{
void PaintIt(object sender, System.Windows.Forms.PaintEventArgs e)
{
}
}
and the to call the method inside the paint delegate of the form, e.g.
void MainFormPaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
myRect.PaintIt(sender, e);
}
where, of course, myRect is member of the form.
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Is it possable to make a variable in a function persistant without declairing it outside of the function?
That is, retain its value between calls to that function while still allowing it to be changed.
e.g.
private void MyFunction(string sSillyGarbage)<br />
{<br />
int iMyPersistantVariable;<br />
}
Thanks,
David Wilkes
|
|
|
|
|
amatbrewer wrote: Is it possable to make a variable in a function persistant without declairing it outside of the function?
No, that is not possible. The local variables in a method are allocated on the stack when the method is called, and deallocated when it returns.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
Guffa wrote: It's amazing to see how much work some people will go through just to avoid a little bit of work.
"Its hard work, being this lazy!"
David Wilkes
|
|
|
|
|
The general answer is no: C# has no equivalent to the "static" keyword applicable
to local variables in a function (but C and C++ do).
There is one exception (starting .NET 2.0): within an iterator, a function can
"yield return" which means its locals remain alive and keep their value.
See MSDN for more info and examples.
Luc Pattyn
|
|
|
|