|
Hi all,
I'm trying to set the color property of a listbox control to a custom color, more specificly:
Blue: 178
Green: 169
Red: 162
#A2A9B2
How can I do this?
Many thanks in advacne
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
<br />
using System.Drawing<br />
<br />
ListBox.BackColor=Color.FromArgb(178, 169, 162);<br />
|
|
|
|
|
|
Hi,
Any idea how to compile to an older version of .net??
I'm running VS 2005 and I'm using CSharpCodeProvider to compile some code however; I want it to be compiled to an older .net version (ie 1.1).. Any idea how to do it even in a tricky way?? maybe by importing that library from .net 1.1, please help guys
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
|
Looks helpful, thanks Dave!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
At the command line? That's easy.
|
|
|
|
|
Excuse me
How??
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
By calling the appropriate csc.exe .
There's a different version for each .NET version.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
|
You'll have to call %WINDIR%\Microsoft.NET\Framework\v1.1.4322\csc.exe to get the C# compiler for .NET 1.1.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
|
Hi All,
I want to write some application in Doc/view architecture -
What i mean is that i want it to be like Doc/view in the MFC ( like explorer style )
Can i do it in C# ?
If i can - so how to do it ?
Thanks for the help.
|
|
|
|
|
You create a document, then map a view onto that document. Although, you may be better off considering the Model View Controller pattern, as this allows you to connect multiple views to one model (document). Here's a pseudo .NET 3.5 version.
public abstract class ModelBase
{
public ModelBase()
{
Title = string.Empty;
FileLocation = string.Empty;
}
public string Title{ get ; set; }
public string FileLocation { get ; set; }
public abstract void FileSave();
}
public class MyDocument : ModelBase
{
public MyDocument() : base() {}
public override void FileSave()
{
}
}
public abstract class ViewBase<T> where T : ModelBase, new()
{
public ViewBase(T model)
{
Model = model;
}
protected T Model { get ; set ; }
public abstract void Refresh() {}
}
public class MyView : ViewBase<MyDocument>
{
public MyView (MyDocument doc) : base (doc)
{
}
public override void Refresh()
{
}
}
public class ControllerBase<T, U>
where T : ModelBase
where U : ViewBase
{
private T _model;
private List<U> _views = new List<U>();
public ControllerBase(T model)
{
_model = model;
}
public void AttachView(U view)
{
_views.Add(view);
}
public void RefreshAll()
{
foreach (ViewBase view in _views)
{
view.Refresh();
}
}
} I've just typed this into IE, so I apologise if the syntax isn't 100% correct but this should get you started.
|
|
|
|
|
Hi,
I develop an application by visual studio 2005, programming language C#, and doesn't used any other style tools.
After used my application, my friend give me his opinion that I shouldn't use office 2003 menu because it doesn't suite with GUI. he said I should use native vista menu. I think it's good idea so I want to change style menu, but In visual studio 2005, (menu option) Render Mode have 3 options: System, Programming, ManagerRenderMode.
I found out that Microsoft support a class VisualStyleElement but I don't know how to used it!
I wish some one can show me how to use VisualStyleElement class. I took a look at some sample in MSDN website but I didn't clearly understand.
Thanks
|
|
|
|
|
KienNT78 wrote: VisualStyleElement but I don't know how to used it
Google it.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Google didn't help...All results are unuseful...
|
|
|
|
|
I have very large application its multi threaded as well now is it possible to know which methods was invoked like stack trace without having a breakpoint. The application has no error but i need to know which method of which class got executed.
|
|
|
|
|
|
I have a WS that has a number of methods, and two in particular must share a file. My question is, will the finally block in the following code run while the lock is acquired, or will it release the lock, then run the finally block?
public byte[] GetFile(string fileName) {
FileStream fs = null;
try {
lock (s_Lock) {
fs = new FileStream(..., FileShare.None, ...);
byte[] result = new byte[fs.Length];
fs.Read(result, 0, fs.Length);
return result;
}
} finally {
if (fs != null)
fs.Close();
}
}
public bool DeleteFile(string fileName) {
lock (s_Lock) {
File.Delete(fileName);
}
} The thing I am worried about is that I am opening the file with no sharing allowed, so I want other calls for the same file to wait for the file to become accessible. So if GetFile is currently being run (has the lock) and DeleteFile is waiting for the lock (both with the same file name argument), then is it possible that prior to the call to fs.Close() that the DeleteFile method attempts to remove the file (which would result in an exception since the file is already open)? Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Yes, you do have a race condition. The lock block's scope is within the try block, so it is essentially
try
{
try
{
Monitor.Lock(s_Lock);
...
}
finally
{
Monitor.Unlock(s_Lock);
}
}
finally
{
if (fs != null)
fs.Close();
}
So yeah, DeleteFile could potentially run in parallel with the finally block.
Moving the lock block outside try/finally solves the problem. And if all you're doing is closing the FileStream in the finally block, you might want to use a using statement instead. Like
lock(s_Lock)
{
using(FileStream fs = new FileStream(...)
{
fs.Read(...);
}
}
Hope that helps.
|
|
|
|
|
Thanks for the help!
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
With Martin Luther King Day approaching, we should all look to eliminate race conditions.
|
|
|
|
|
PIEBALDconsult wrote: With Martin Luther King Day approaching, we should all look to eliminate race conditions.
I have a dream that one day this operating system will rise up and live out the true meaning of its creed "We hold these truths to be self-evident: that all threads are created equal and shall not interfere with each other."
|
|
|
|
|
Hello Everyone!!
I'm trying to add a delegate to a Dictionary<string, object>, hence of running it through IronPython (script file).
I have managed this (look at the code) but now I want to do this dynamic. In other words I don't want
to declare a delegate for every method in my class (ExCode. AddItem in Actor).
The problem is the method CreateDelegate and the first argument. I can't bind a dynamic type representing the type of delegate to create. I have not found a solution for this on CodeProject but where is greatly on the subject.
Dynamic Code Generation vs Reflection By Herbrandson
Fast late-bound invocation through DynamicMethod delegates By Alessandro Febretti
A General Fast Method Invoker By Luyan
This is the code:
<br />
using System.Reflection;<br />
using IronPython.Hosting;<br />
<br />
public class Actor<br />
{<br />
private string objectID;<br />
private int count;<br />
<br />
public void AddItem(string objectID, int count)<br />
{<br />
Console.WriteLine(string.Format("{0}, {1}", objectID, count));<br />
this.objectID = objectID;<br />
this.count = count;<br />
}<br />
}<br />
<br />
public class ActorScript<br />
{<br />
protected delegate void AddItem(string objectID, int count);<br />
protected Dictionary<string, object> locals = new Dictionary<string,object>();<br />
protected Actor actor;<br />
<br />
ActorScript(Actor actor)<br />
{<br />
this.actor = actor;<br />
Initiate();<br />
}<br />
<br />
private void Initiate()<br />
{<br />
MethodInfo methodInfo = typeof(Actor).GetMethod("AddItem", BindingFlags.Public | BindingFlags.Instance);<br />
this.locals.Add("AddItem", Delegate.CreateDelegate(typeof(AddItem), this.actor, methodInfo));<br />
<br />
}<br />
<br />
public void Run(string fileName)<br />
{<br />
PythonEngine engine = new PythonEngine();<br />
engine.ExecuteFile(fileName, this.engine.DefaultModule, this.locals);<br />
}<br />
}<br />
<br />
This is the script file:<br />
<br />
ItemScript.py<br />
AddItem("Sword", 2)<br />
Any help would be appreciated.
Best Regards,
Gywox
modified on Tuesday, January 15, 2008 5:13:06 AM
|
|
|
|