|
Well, I wonder how you expect to write a working application if you do not understand the basics.
However
- Use your mouse to right-click on the References item in Solution Explorer.
- Select the .NET tab in the popup dialog.
- Scroll down to System.Windows.Forms, and select it.
- Click on OK.
- Add the
using statement to your source module.
[edit]Did I say something wrong here? Got a 1 vote for it anyway[/edit]
It's time for a new signature.
modified on Thursday, July 1, 2010 1:57 PM
|
|
|
|
|
I have noticed that some people down-vote things they don't want to hear, regardless of veracity or technical merit.
I wouldn't let it get you down.
|
|
|
|
|
Timothy CIAN wrote: I wouldn't let it get you down.
Oh, it doesn't; I make too many mistakes to worry about criticism. I would just prefer to have an explanation of what I did wrong.
It's time for a new signature.
|
|
|
|
|
i found an answer...
right click on the solution and then add reference of System.Windows.Forms
this solves my problem..
|
|
|
|
|
How to extend fixed scope?
I've got array of byte* native pointers and I need to assign them managed byte[] arrays. But that can be done in a fixed {} block statement.
Чесноков
|
|
|
|
|
You can get a permanent fix through the GCHandle class. It is used in here[^] for passing arrays.
|
|
|
|
|
that is what I was looking for, thanks
Чесноков
|
|
|
|
|
you're welcome.
|
|
|
|
|
Hi Experts,
I am new to C#,I am trying to use
HashSet stringSet = new HashSet { "abc", "aa" };
Bu i am getting error as "A new expression requires () or [] after type"
Whethier i should include any header file.
Thanks
Raj
|
|
|
|
|
try this:
HashSet<string> stringSet = new HashSet<string> { "abc", "aa" } ;
|
|
|
|
|
HashSet<string> stringSet = new HashSet<string>() { "abc", "aa" };
foreach (string s in stringSet) log(s);
works well on .NET 3.5 or 4.0
FWIW: the constructor parentheses are optional here!
|
|
|
|
|
Hi sir,
I tried the above but i am getting error as "{ "abc", "aa" };"
For this line ,its getting error
Error 1 ; expected E:\WindowsApplication1\WindowsApplication1\Form1.cs 66 63 WindowsApplication1
Error 2 ; expected E:\WindowsApplication1\WindowsApplication1\Form1.cs 66 70 WindowsApplication1
Error 3 Invalid expression term ',' E:\WindowsApplication1\WindowsApplication1\Form1.cs 66 70 WindowsApplication1
Error 4 ; expected E:\WindowsApplication1\WindowsApplication1\Form1.cs 66 72 WindowsApplication1
Error 5 ; expected E:\WindowsApplication1\WindowsApplication1\Form1.cs 66 77 WindowsApplication1
|
|
|
|
|
|
The collection initializer syntax "new X { elements } " is new in C# 3.0. The error message looks like you're using a C# 2.0 compiler (VS 2005?).
You could rewrite this snippet to C# 2.0 by using explicit calls to Add(), but that still won't help you as the HashSet class is new in .NET 3.5 as well.
HashSet<string> stringSet = new HashSet<string>();
stringSet.Add("abc");
stringSet.Add("aa");
|
|
|
|
|
Hi
I have a libary with some user controls which are used on different projects. What i want to do is when one of these controls are place on a form, you have to set the controls name before its added to the project. Is this possible at all.
Thanks
Chris
Chris
|
|
|
|
|
hiiiii,
for me it sounds you developed your own Designer ?!??
in that case you need to implemented the INameCreationService.
|
|
|
|
|
hi
No i havent developed my own designer. Just that i want to be promted to input the controls name
Chris
|
|
|
|
|
If what you are asking is "When a designer drags my UserControl from the ToolBox to his form, he should be prompted to set the controls Name property - how do I do it?" Then AFAIK you can't. And you probably shouldn't if you can. If you did, it would make your control very different from the normal VS controls, and would probably really annoy some developers. Most of us do not use the default name fro most controls, preferring "tbPrintStatement" to "button52", but even I do not rename labels and so forth! If VS started insisting I did, I would be a bit pissed off.
Generally, I place my controls as a bunch, then change the name and text at the same time.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Yes thats what i'm trying to do. I have wrote a set of controls for an HMI. the idea is to remove as much of the need for code as possibel so that some of my fellow engineers can do simple changes to the screens.
It would be really anoying if all controls did this but we just want the ones we have designed.
Chris
|
|
|
|
|
Nasty! If you are letting your engineers make "simple changes to the screens" you do realise they will need full VS to do it? Which means they could do anything to your screens. Including f@ck them up completely...
If these guys are not bright enough to be trusted with default names and the ability to change them, then why are you going to trust them not to make a complete pigs-ear of the whole system?
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
hmmm i have to agree with you every time a promting for the name would suck
actually you need to write an addin for the IDE (VS oder #Develop).
The addin should override the INameCreationService of the DesignerHost.
then you can create a name the "normal" way or prompt for it
sooo far
|
|
|
|
|
alright i have the solution worked out!!
but you need to wait till i am at home i will write an article about your problem because this is very interesing stuff
so please be patient..
greetz all over the world
|
|
|
|
|
ok
Thanks in advance
Chris
Chris
|
|
|
|
|
|
Ok so you may have seen my very basic question yesterday and I'm back today to build the project up and could use some pointers on virtual and abstract and how to apply them.
In a nutshell my project has a FruitBase class that simply establishes private fields and then public properties that each individual fruit will have.
public class FruitBase
{
private string _name;
private string _colour;
public FruitBase()
{
}
public virtual string Name
{
get { return _name; }
set { _name = value; }
}
public string Colour
{
get { return _colour; }
set { _colour = value; }
}
}
I then have individual fruit classes eg. apple, banana etc. that set the default values within thier constructors, eg.
public class Apple: FruitBase
{
public Apple()
{
this.Name = "Apple";
this.Colour = "Red";
}
}
The idea is the user selects a radio button for a fruit type and we then return the defaults on a button press, which runs the function GetValues().
<asp:RadioButtonList runat="server" ID="radList" RepeatDirection="Horizontal">
<asp:ListItem Text="Apple" Value="Apple" />
<asp:ListItem Text="Banana" Value="Banana" />
<asp:ListItem Text="Orange" Value="Orange" />
<asp:ListItem Text="Pear" Value="Pear" />
</asp:RadioButtonList>
<asp:Button runat="server" ID="btnFruit" Text="Get" OnClick="GetValues" />
<br />
<br />
<asp:TextBox runat="server" ID="txtOuput" TextMode="MultiLine" Width="250px" />
The issue is I am trying to avoid is a long-winded, repetative piece of code such as
public void GetValues(object sender, EventArgs e)
{
string Ftype = FruitBase.GetType();
if(Ftype = Apple)
{
}
else if(Ftype = Banana)
{
}
else.........
}
As you can imagine if I include every type of fruit in a supermarket as an option I'll quickly end up with hundreds of lines of code.
So, to my (admittedly basic) knowledge, I should be able to create a virtual method within the FruitBase class that takes an object of FruitBase as a parameter and will then retrieve the default values of the users chosen fruit without any explicit mention of the chosen class (Basically avoiding any long if statements).
Immediately I'm stuck however.
First of all, how do I use the radio buttons selectedValue to specify the chosen fruit class, without another if(value = "Apple") else.....
Secondly how do I then pass this as an object and have the virtual method retrieve the default values from the correct class without being explicit and again avoiding the if..else situation mentioned above.
I realise this is a little long winded and I'm not great with the correct terminology but this was an example technical test at a recent job interview and I didn't get it so now I want to get my head round it.
Thanks for reading and any help is greatly appreciated
|
|
|
|