|
I looked at D a few years back, and as far as I'm concerned it's C++ with added sugar (and garbage collection). Neither language fixes all the shortcomings of C.
On the other hand, when considering C# it's not so much a question of the language itself, because C# targets the .net framework which, for me, far outweighs any particular language features and really invalidates any comparison.
I use C# regardless of the size of the project, though I still use C a little bit as well.
|
|
|
|
|
Hello, I have a multiple textboxes in a form.
I read in values from a textbox, and depending on what is read in, values are sent to certain textboxes. However I am not able to do this dynamically.
---textfile---
ownerFields_text
--------------
private void writeToApp(string readIn)
{
TextBox txtBox = new TextBox();
txtBox.Name = readIn;
txtBox.Text = "Why wont this work"; //line doesnt work ownerFields_text.Text = "hello"; //line works
}
Although looking in the properties in the debug windows for txtBox,shows property name=ownerFields_text, but its just not printing "Why wont this work". I do not want or cant cycle through controls for the right one.
Thanks.
jimmy
|
|
|
|
|
j_sen wrote: TextBox txtBox = new TextBox();
txtBox.Name = readIn;
txtBox.Text = "Why wont this work";
So you create a new TextBox, give it a name and some text.
Fine.
This has nothing to do with other TextBoxes that may already exist.
It will not magically point to an existing TextBox with the selected name!
If you want to set the text of MyFirstTextBox, the one direct way to do this is
by MyFirstTextBox.Text="new text";
If you want to modify one of many existing Controls, you either need:
1. a lot of code (one piece for each Control), say a switch
2. or a Dictionary that maps names onto Controls
3. or Reflection
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: If you want to modify one of many existing Controls, you either need:
1. a lot of code (one piece for each Control), say a switch
2. or a Dictionary that maps names onto Controls
3. or Reflection
4. or the Find method.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
right.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
j_sen wrote: Although looking in the properties in the debug windows for txtBox,shows property name=ownerFields_text, but its just not printing "Why wont this work".
You are creating a new control that isn't displayed anywhere. Giving it the same name as another control doesn't automatically transform your new control into that control. They are still separate objects.
j_sen wrote: I do not want or cant cycle through controls for the right one.
If you don't have a reference to the control, you have to. You can use the Find method to do it for you.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
I want to add some visio shapes into my win form
programmatically ,i have to read some data from DB and
show the required diagram,
any body would help,
thanks
|
|
|
|
|
This might help you: http://msdn.microsoft.com/msdnmag/issues/03/12/Visio2003/default.aspx
|
|
|
|
|
Hi,
I am currently developing some application which have a lot of controls on them, especially an explorer bar which when the application window appears, is actually empty and white for a few seconds and then it is populated.
I am wanting to know if it possible and how I would implement a splash screen that is shown and updates a status label on the splash form, which stays until all the controls on my mainForm have been drawn and populated.
I am programming in C# in the MS Visual Studio 2005 (Vista) environment.
Thanks, Andrew Robinson.
|
|
|
|
|
Hi Andrew,
a splash screen is a popular topic, I suggest you search CodeProject for
some highly rated articles about it.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
In fact, NONE of the splash screen components/classes I saw for .NET were of any use to me.
And I search a lot and found a lot...
|
|
|
|
|
Really? Maybe you should write an article about the subject then...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
No chance - I have no clue either; otherwise I wouldn'T have searched
|
|
|
|
|
I thought there was a splash screen component built in, but a splash screen is just a form. Use the Show method so that it doesn't stop the rest of your app from running.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I am using a lot of controls on my main form, and require the splash screen to be shown until all the controls are drawn. I am using the AppLoader Quick n Dirty in C#. I have the splash working but don't know how to make it stay until the main form has completed loading and populating a control.
Any help is appreciated.
Thanks, Andrew.
|
|
|
|
|
Hi, maybe you should use the Activated-Event of the main form. This event occurs when the form has completed loading!
Tobias
|
|
|
|
|
i want my code to accept only numbers as the input in this calculator code.....how can i do that
class Program
{
int operand1;
int operand2;
char oper;
int result;
public void Display()
{
Console.WriteLine("Enter the value of operand1");
if (operand1 < 48 && operand2 > 57)
{
Console.WriteLine("");
}
operand1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter the value for operand2");
operand2 = Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter the oper");
oper = Convert.ToChar(Console.ReadLine());
}
public void Result()
{
switch (oper)
{
case '+':
result = operand1 + operand2;
break;
case '-':
result = operand1 - operand2;
break;
}
}
public void Displayresult()
{
Console.WriteLine("{0} ", result);
Console.ReadLine();
}
public static void Main()
{
Program obj = new Program();
obj.Display();
obj.Result();
obj.Displayresult();
}
}
}
thanks
C#
|
|
|
|
|
Use Int.TryParse() in order to check if the string is an integer
|
|
|
|
|
hi ,
thanks but can you be bit more specific ie wer should i use this
thanks
C#
|
|
|
|
|
You should use it instead of Int.Parse() Have a look at documentatio in MSDN, it shows how to use Int.TryParse()
|
|
|
|
|
Hello,
I wrote the following code to get a list of available drives letters:
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.IO;<br />
<br />
namespace drives<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
int intFirstDrive = Convert.ToInt32('A');<br />
int intLastDrive = Convert.ToInt32('Z');<br />
List<int> intAvailableDrives = new List<int>();<br />
for (int i = intFirstDrive; i <= intLastDrive; i++)<br />
{<br />
intAvailableDrives.Add(i);<br />
}<br />
<br />
DriveInfo[] usedDrives = DriveInfo.GetDrives();<br />
int x = usedDrives.Length;<br />
<br />
foreach (DriveInfo usedDrive in usedDrives)<br />
{<br />
int intUsedDrive;<br />
string strUsedDrive;<br />
char chrUsedDrive;<br />
strUsedDrive = usedDrive.Name.Substring(0, 1);<br />
chrUsedDrive = Convert.ToChar(strUsedDrive);<br />
intUsedDrive = Convert.ToInt32(chrUsedDrive);<br />
intAvailableDrives.Remove(intUsedDrive);<br />
}<br />
<br />
List<string> strAvailableDrives = intAvailableDrives.ConvertAll<string>(delegate<br />
(int intDrive)<br />
{<br />
return Convert.ToChar(intDrive).ToString();<br />
});<br />
}<br />
}<br />
}<br />
but it seems that in windows vista DriveInfo.GetDrives() doesn't get network drives, is there something I can do about it?
|
|
|
|
|
|
Hello, everyone.
I was working on a windows program with C#, and wanted to associate my PictureBox component with a ContextMenu.
I searched into the Properties Windows, only to find a ContextMenuStrip property there instead of a ContextMenu.
Then I was unable to set the property using the Properties Window which would otherwise save me a lot of troubles.
So here comes my question. Since not all the properties of a component are displayed on the Properies Window, can I manually put the ContextMenu or some other property onto the Properties window? Or there's just no way for me to customize the Properties Window like that?
-- modified at 6:25 Saturday 20th October, 2007
|
|
|
|
|
ContextMenuStrip, is just a context menu, 'they' just changed the name a little.
Make yourself a ContextMenu(Strip) then set your Picture boxes ContextMenu(Strip) to it.
And in a situation where a property is not listed in the designer, and you KNOW its there, you can just add the line of code yourself, like:
this.Thing.Attribute = Whatever;
I don't think you can just add stuff tou the properties window like that. You'd have to inherit the base class, and add in the support for the designer.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Thanks for your advice!
|
|
|
|