|
The errors give you the answer!
In your ClassLibrary1 project, in Solution Explorer, right click on References, choose Add Reference and under the .NET tab click System.Drawing and click OK. Repeat for System.Windows.Forms.
There is no need to post the same reply twice by the way
|
|
|
|
|
Thanks a lot. A class has been successfully created but when i create a from and the colored button control does not appear in the tool box.
|
|
|
|
|
 I have created the class but its giving me errors when i build the application:
here is the code
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace ClassLibrary1
{
public class ColoredButton
{
public static readonly Color DefaultColorA = Color.Red;
public static readonly Color DefaultColorB = Color.Green;
public const int DefaultInterval = 1000;
public event EventHandler Tick;
private Color colorA;
private Color colorB;
private Timer timer;
public ColoredButton()
{
colorA = DefaultColorA;
colorB = DefaultColorB;
BackColor = colorA;
timer = new Timer();
timer.Interval = DefaultInterval;
timer.Tick += TimerTick;
}
public Color ColorA
{
get { return colorA; }
set { colorA = value; }
}
public Color ColorB
{
get { return colorB; }
set { colorB = value; }
}
public int Interval
{
get
{
if (timer != null)
return timer.Interval;
else
return DefaultInterval;
}
set
{
if (timer != null)
timer.Interval = value;
}
}
protected override void Dispose(bool disposing)
{
if (disposing && timer != null)
{
timer.Dispose();
timer = null;
}
base.Dispose(disposing);
}
protected virtual void OnTick(EventArgs e)
{
EventHandler eh = Tick;
if (eh != null)
eh(this, e);
}
public void Start()
{
if (timer != null)
timer.Start();
}
public void Stop()
{
if (timer != null)
timer.Stop();
}
private void TimerTick(object sender, EventArgs e)
{
if (BackColor == colorA)
BackColor = colorB;
else
BackColor = colorA;
OnTick(EventArgs.Empty);
}
}
}
Errors:
The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\XPPRESP3\Local Settings\Application Data\Temporary Projects\ClassLibrary1\ColoredButton.cs 40 16 ClassLibrary1
Error 1 The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Documents and Settings\XPPRESP3\Local Settings\Application Data\Temporary Projects\ClassLibrary1\ColoredButton.cs 4 14 ClassLibrary1
|
|
|
|
|
i m working in c#.How to insert values in text box at run time in window application and compare it with the int.can any one tell me.any help will be appreciated.
Thamks
|
|
|
|
|
Your question isn't 100% clear: are you asking how to move values from a number (say an int ) to a TextBox, and then back from a TextBox to a number again?
If so, then:
int i = 12;
double d = 12.776;
textBoxIntegerValue.Text = i.ToString();
textBoxDoubleValue.Text = d.ToString(); You can apply formatting information in the ToString method if you need to. See MSDN[^] for more info.
To go back to a number:
int i;
double d;
i = int.Parse(textBoxIntegerValue.Text);
d = double.Parse(textBoxDoubleValue.Text);
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Thanx.But i want that how to insert values at run time in text box after debugging the program not defining a variable and inserting values in text box.Is there any function??
|
|
|
|
|
First Ur question is not appropriate
For Inserting Values into the textbox is Textbox.Text
If you can think then I Can.
|
|
|
|
|
But i want to put the values in text box after running the program.Whenever i run the program i can put any value in text box that should be assigned to any other variable.I donont want to assign the values to text box as:
Textbox.text="good";
Not like this but to insert values at run time and convert it to int and assign it to any variable,
|
|
|
|
|
if u want to assign value in textbox then use Textbox.Text
but if you want to assign value in variable then use String s = textbox.text
if u want to convert value from string to int then use Int32.Parse("string value")
Best Regard
If you can think then I Can.
|
|
|
|
|
Sorry, but that doesn't make a lot of sense to me - it is probably a language translation problem.
Could you try to explain in more detail?
Try breaking it up into stages:
"I have a TextBox on my form called textBox1"
"I want to put a value into textBox1 so I can read it"
"I want to get the value from..."
And so on?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Actaully i have put text box on form in window application. Now what i want to do that whenever program is run i can give any value in the text box.The value that i insert that time in the text box after running the program should be assigned to int. I donont want to assign the values to text box as:
Textbox.text="good";
Not like this but to insert values at run time and convert it to int and assign it to any variable,
|
|
|
|
|
Ah! I think you mean:
"I want to let the user type a value into the text box, and then convert it to a number in a variable in my program"
You can convert the TextBox content to a number at any time:
int i = int.Parse(textBox1.Text); Will convert the content to an integer and store it in the variable i.
Why is this causing a problem? What do I still not understand about your problem?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Do you mean you want your code to place a random number in the text box?
|
|
|
|
|
yes any number that i put in text box.
|
|
|
|
|
Hello,
I am writing a program which transfers music files to devices like iPod and other mp3/music player. I am done with iPod, I use ITunes library for that and able to list and sync music in device. I could find Apple device using WMI query,
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "Select * from Win32_PnPEntity Where Name Like '%Apple%'");
But I am not able to do it with other devices. Problem is I am not finding any WMI query to detect weather device is music player or portable device. I wanted to use Windows Media Player for Sync music files to music player.
Any help is appropriated.
Thanks in advance
|
|
|
|
|
Hello Everybody,
I want to know that how to send mail from localhost.
Help me.
Thanks
If you can think then I Can.
|
|
|
|
|
Questions like this can be researched quite easily by using the tools at your disposal. For example a simple Google search reveals this[^].
I must get a clever new signature for 2011.
|
|
|
|
|
Dear Sir,
I already find it but i want for local host.
If you can think then I Can.
|
|
|
|
|
eg_Anubhava wrote: i want for local host.
What do you mean by this?
I must get a clever new signature for 2011.
|
|
|
|
|
I want to know that how to send mail with the use of localhost without using crediential.
If you can think then I Can.
|
|
|
|
|
Hi,
The way you ask let me think you're not aware of what is localhost really.
Localhost represents you local computer. So, if you want to send mail from localhost, it means you have to have a SMTP service running on your computer.
Do you have configured a SMTP service on your computer ?
Furthermore, I don't recommend you to send mails directly from your local computer, if you are on a private ISP subscriber line. Most of antispam systems check several things when they receive messages :
1 - They check that an MX entry exist in the DNS for the mail system contacting them
2 - Some even check that the reverse DNS is giving a correct computer name
In case you try to send mail from a private DSL IP address, you have many chances to have your IP address blacklisted by major antispam databases.
But it's just a guess...
|
|
|
|
|
thanks sir
If you can think then I Can.
|
|
|
|
|
Hi,
I fetch my connection string like this:
connectionString = Properties.Settings.Default.KTReunionConnectionString;
Which works perfectly. However I want to give the user the ability to name the database and update the string. Any attempt using the method below gives a compiler message that it's read only. How do I get around this?
Properties.Settings.Default.KTReunionConnectionString = connectionString;
I've tried this, however it doesn't not update in the app.config file:
var mySettings = ConfigurationManager.ConnectionStrings[0];
var cf = typeof(ConfigurationElement).GetField("_bReadOnly", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
cf.SetValue(mySettings, false);
mySettings.ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=" + databaseName + "Integrated Security=True";
Is it possible to update the connection string?
Thank you,
Glenn
|
|
|
|
|
This may seem like a great idea, but you have to consider that the app.config file sits in the same folder as your .EXE, under Program Files. The problem with this is under Vista and Win7, users only have read permissions to everything under Program Files. This means that when they run the app, they cannot update the app.config file.
Either you have to prompt for and set these things at installation time (which requires an Admin account anyway) or you have to put the settings in a file under the users profile if you're going to allow each user to have their own seperate settings.
|
|
|
|
|
That would be a reason to not use that config scheme; I always make my own config files.
|
|
|
|