|
Random rand = new Random();<br />
byte[] rgb = new byte[3];<br />
rand.NextBytes( rgb );<br />
Color color = Color.FromArgb(rgb[0], rgb[1], rgb[2]);
|
|
|
|
|
Thank you gleat.. Actually, I was managing it that way and wanted to use the pre-defined colors in the Color object.
Thanks for your help!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
If you only want to use webcolors you can use the result from a function like this one.
<font>IEnumerable<color> GetColors()
{
foreach (PropertyInfo p in typeof(Color).GetProperties(BindingFlags.Public | BindingFlags.Static))
{
if (p.Name.ToLower() != "transparent")
yield return (Color)p.GetValue(null, null) ;
}
}
</color></font> Last modified: 55mins after originally posted --
Standards are great! Everybody should have one!
|
|
|
|
|
Thanks Bekjong!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
i have a problem when i press enter then what ever i hav written in textbox is cleared but cursor comes in next line so please tell me how to get my cursor in first line only not to move in second line on ENTER
|
|
|
|
|
You need to explain better. When you press enter, the text is cleared ? How ?
If you don't want to move to a second line, make your control not multiline
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Probably Shift+Enter is what you're looking for!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
i think u r looking for multiline textbox if it is the issue
use
textBox1.AcceptsReturn = True
|
|
|
|
|
Hi all
I require to store a location path in my web.config file and then use this path in my application by using
mypath = ConfigurationManager.AppSettings["mypath"]
however, this path is being used to load in a dll, like so
[DllImport(mypath+"mydll.dll", EntryPoint="runme", ExactSpelling=true, SetLastError=false, CallingConvention = CallingConvention.Cdecl)]
and because the DllImport is in the head of the class (before any methods) I require to create the path as a constant string, like so
const string mypath= "C:\\mypath\\"
now this works if I don't use the ConfigurationManager to get my path from the web.config and I hard code the path into the class. However, I dont want the path hard coded in.
If I do this though
const string mypath=ConfigurationManager.AppSettings["mypath"]
It complains and says:
Error 7 'myclass.mypath' is of type 'string.' A const of reference type other than string can only be initialized with null
I'm confused by this because I thought ConfigurationManager.AppSettings["mypath"] returned a String, so why cant I just use that?
Does anyone know how to do this?
|
|
|
|
|
You should use reflection
1.in runtime Dynamicly write a method
2.Add DllImport Attribute to it and add dll path
3.Invoke the method
by Sedat Kurt
|
|
|
|
|
Could you give me an example of this please?
|
|
|
|
|
|
thestonefox wrote: Error 7 'myclass.mypath' is of type 'string.' A const of reference type other than string can only be initialized with null
I'm confused by this because I thought ConfigurationManager.AppSettings["mypath"] returned a String, so why cant I just use that?
It looks like the variable mypath is declared as a const. You are probably declaring this a member variable though. your line of code probably looks like public const string mypath = ConfigurationManager.AppSettings["mypath"] . Try not declaring the variable as a constant, and it should work.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
The variable has to be a constant as it is used in
[DllImport(mypath, EntryPoint="runme", ExactSpelling=true, SetLastError=false, CallingConvention = CallingConvention.Cdecl)]
where mypath is used is outside the main constructor so it requires to be a constant
|
|
|
|
|
thestonefox wrote: mypath = ConfigurationManager.AppSettings["mypath"]
mypath cannot be constant. Constants are "baked" into assembly at compile time. Value from configuration file is taken at run time.
thestonefox wrote: [DllImport(mypath+"mydll.dll", EntryPoint="runme", ExactSpelling=true, SetLastError=false, CallingConvention = CallingConvention.Cdecl)]
Also you can't do this, attributes are metadata, again compile time.
What Sedat said should work (I don't know if there is any way how to imperatively do dll import, you could try your luck with Google/MSDN on PInvoke).
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
I think the easiest thing to do would be to write a native DLL in C/C++ that dynamically loads DLLs via LoadLibrary and GetProcAddress and calls "runme". Your DLL function might be declared like this:
void CallRunme( const TCHAR *pszDLL, int param1, int param2 ); Call this from .NET via PI and pass the DLL name as the first param.
|
|
|
|
|
FileInfo thefile = new FileInfo(MapPath("RtfFilesPath") + "\\" + txtOriginalName.Text);
if (thefile.Exists)
{
File.Copy(MapPath("RtfFilesPath") + "\\" + txtOriginalName.Text, MapPath("RtfFilesPath") + "\\" + txtFilename.Text);
}
this is the snippet i am using in my code this is working fine but it is expecting me to type the whole filename with extension.can anybody suggest me what to do to if i want to ignore the extension of the file for the original filename which is in the txtOriginalName.text
iwant to give only the filename before the . in the textboxes
regards
sunilwise
-- modified at 4:58 Monday 12th November, 2007
|
|
|
|
|
Why do you think that you need a MSDN subscription for sharing your own code??
|
|
|
|
|
I mean, ya.. at least, you wrote this program, right? and you don't read the Microsoft Shared Code which are under the MS ref license, rigth? then, I think you won't need MSDN subscription for distributing your program... If you want more details about confirmation, you can probably contact with Microsoft..
|
|
|
|
|
In the drop dowm list (ASP.Net) control we can bound the display text and the value of the item.
Same way, is there any other option to bound the display value and the item value separately.
There is a property selected value for the combo box, but there is no option to specify the value for that property.
Can any one suggest me a control for it.
Thanks in advance.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
M. J. Jaya Chitra wrote: here is no option to specify the value for that property.
you mean, SelectedIndex??
M. J. Jaya Chitra wrote: is there any other option to bound the display value and the item value separately.
Can you tell us more about what you wanna do?
|
|
|
|
|
My target is to bind the description and the id of that description to a combo box.
For this now I have found one solution to use the "ValueMember" property.
Thanks for you time.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
cool...
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
hi iam in a little bit of confusion how to add webreferences dynamically in .net can anybody helps me
|
|
|
|
|
If you add a web reference allready in your application then set its property to Dynamic. After that Suppose on a button's click write this
Myref is the service name Ok. And client is a object of that.
Myref.MyRef client = new Myref.MyRef();
client.Url = "Web reference URL"; //put new URL here.
client.Methodname(parameters);
Hope this helps
-- modified at 3:53 Monday 12th November, 2007
Regards
Pankaj Joshi
|
|
|
|