|
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
|
|
|
|
|
Luc Pattyn wrote: C# has no equivalent to the "static" keyword applicable
to local variables in a function (but C and C++ do).
Which I consider to be a wise decision.
Declaring a static variable in a method means that it's created at class level, not as a local variable. I find it more logical to declare it where it is created.
Also, if a method could have static "local" variables, there should also be an "instance" keyword so that you could declare non-static class level "local" variables.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
I beg to differ, yes the compiler/linker will allocate a function-local static variable outside the function (to keep it alive when the function returns),
but its scope is limited to the function itself, making it inaccessible to
other functions (encapsulation), which is not what you get by declaring
a (static or other) variable outside the function.
So it has a purpose, and I would not mind C# offering the same possibilities.
Luc Pattyn
|
|
|
|
|
Luc Pattyn wrote: I beg to differ, yes the compiler/linker will allocate a function-local static variable outside the function (to keep it alive when the function returns),
but its scope is limited to the function itself, making it inaccessible to
other functions (encapsulation), which is not what you get by declaring
a (static or other) variable outside the function.
That is exactly what I think is the problem. Normally the scope of a variable is consistent with where it's stored, but allowing "local" static variables creates a variable where the scope differs substantially from where it's stored.
This is not encapsulation. That is done on class level, not inside a class.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
I have a name that is in the format: Lastname, Firstname
I want to split this string into two strings.
Example name: Smith, John
The problem is I don't know the length of the name so I'm thinking maybe a Regex that works until it hits the comma then skips the space and takes the rest of the string.
Any help is greatly appriciated.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
|
No need for a Regex here:
string name = "Smith, John";
string lastname = name.Substring(0, name.IndexOf(',')).Trim();
string firstname = name.Substring(name.IndexOf(',') + 1).Trim();
Or use String.Split .
If you really want to use a Regex, you can use this one: ([^,]+),([^,]+)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you very much! It works great.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
Hi All
If I add the child nodes of a tree to an array list at run time then when I close the application and again open the application will that nodes be saved in the arraylist and will be accesible at Form loading or they will be vanished if vanished so how shall i save the child nodes in some sort of file or any thing that my be accesible after reopening the application.
Please note i dont want a database or XML to use here
SAS
|
|
|
|
|
You can use a BinaryFormatter to save your ArrayList as Binary into a file and restore it from there again.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
You may want to check out this[^] C# tutorial on network programming to get started.
/ravi
|
|
|
|
|