c#-2.0

How to access namespace which is part of different project?

心不动则不痛 提交于 2019-12-01 23:25:03
问题 I have two C#.net projects project 1 and project 2 (names changed) in single solution. I am using Visual Studio 2005. I have added reference of project 2 in project 1 by right clicking and choosing 'Add Reference'. Both projects are of 'Application' project type not Class library type. I have some classes in project 2 which I want to access in project 1. After adding reference I tried to use import namespace of project 2 in project 1 but I guess its not available. Visual studio Intelisense is

Autocomplete on Combobox onkeypress event eats up the Enter key

為{幸葍}努か 提交于 2019-12-01 20:58:51
问题 I have a ComboBox with AutoCompleteMode = suggest and handle the KeyPress event like so: private void searchBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Return) { // do stuff } } However, it does not catch the Enter key. It catches everything else since the autocomplete dropdown works perfectly. I also tried the suggestion offered here : http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/2db0b540-756a-4a4f-9371-adbb92409806, set the form's

How to access namespace which is part of different project?

倖福魔咒の 提交于 2019-12-01 20:58:29
I have two C#.net projects project 1 and project 2 (names changed) in single solution. I am using Visual Studio 2005. I have added reference of project 2 in project 1 by right clicking and choosing 'Add Reference'. Both projects are of 'Application' project type not Class library type. I have some classes in project 2 which I want to access in project 1. After adding reference I tried to use import namespace of project 2 in project 1 but I guess its not available. Visual studio Intelisense is not showing me the desired namespace. Can anyone please suggest about how to access namespace and

Autocomplete on Combobox onkeypress event eats up the Enter key

我只是一个虾纸丫 提交于 2019-12-01 20:07:59
I have a ComboBox with AutoCompleteMode = suggest and handle the KeyPress event like so: private void searchBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Return) { // do stuff } } However, it does not catch the Enter key. It catches everything else since the autocomplete dropdown works perfectly. I also tried the suggestion offered here : http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/2db0b540-756a-4a4f-9371-adbb92409806 , set the form's KeyPreview property to true and put a breakpoint in the form's KeyPress event handler: private void Form

How do I make a TreeNode not visible? (C#)

拈花ヽ惹草 提交于 2019-12-01 19:50:59
There is probably a really straightforward answer to this but I'm having difficulty finding it. Simple, I have a TreeNode and I would like to make its visibility false. (or another way of not allowing it to be shown until required). Edit - Another Question? I'm confused as to how there isn't a Visible attribute but then there is the property: Node.PrevVisibleNode; What is the difference between this and Node.PrevNode ? Thanks, I don't think you can do that. There is an IsVisible property, but it is readonly and will indicate whether the node is currently visible within the client area of the

Using an 'IN' operator with a SQL Command Object and C# 2.0

对着背影说爱祢 提交于 2019-12-01 19:45:47
I would like to call a sql statement such as: Select * From Table Where Column in ('value1', 'value2', 'value3') Is it as simple as setting a command parameter's value equal to " ('value1', 'value2', 'value3') "? David @Charles: You're going into the right direction, but we're using parametrized queries to mainly prevent SQL injections. Putting 'external' values ( params string[] args ) hardcoded in queries is asking for trouble. You can iterate the arguments, but you still have to use parameters like this: string[] values = new [] {"value1", "value2", "value3", "value4"}; StringBuilder query

HashSet replacement in C# 2.0

∥☆過路亽.° 提交于 2019-12-01 16:29:05
I using List<T> in my project, this list contains hundreds of entries. I am using List.Contains method quite a lot and this is hurting performance, I replaced the List with dictionary but it resulted in memory bottleneck, thus made performance even worst. Is there a better solution that one can suggest for searching in List? Is there a replacement of HashSet<T> in C# 2.0 or some other way that is better both memory and speed wise? A Dictionary<T,bool> can be used in place of a HashSet<T> . Whether you add items with a value of True or False is a coin toss, the value is not relevant. It's more

HashSet replacement in C# 2.0

ε祈祈猫儿з 提交于 2019-12-01 15:38:56
问题 I using List<T> in my project, this list contains hundreds of entries. I am using List.Contains method quite a lot and this is hurting performance, I replaced the List with dictionary but it resulted in memory bottleneck, thus made performance even worst. Is there a better solution that one can suggest for searching in List? Is there a replacement of HashSet<T> in C# 2.0 or some other way that is better both memory and speed wise? 回答1: A Dictionary<T,bool> can be used in place of a HashSet<T>

When should or shouldn't I be using generic type constraints?

…衆ロ難τιáo~ 提交于 2019-12-01 11:37:59
I've got a base class: public abstract class StuffBase { public abstract void DoSomething(); } And two derived classes public class Stuff1 : StuffBase { public void DoSomething() { Console.WriteLine("Stuff 1 did something cool!"); } public Stuff1() { Console.WriteLine("New stuff 1 reporting for duty!"); } } public class Stuff2 : StuffBase { public void DoSomething() { Console.WriteLine("Stuff 2 did something cool!"); } public Stuff1() { Console.WriteLine("New stuff 2 reporting for duty!"); } } Okay, now say I've got a list of items: var items = new List<StuffBase>(); items.Add(new Stuff1());

save image from picturebox in stream format

[亡魂溺海] 提交于 2019-12-01 11:28:31
i wanna save a picture that loaded in a picturebox to stream .when i save in png format it work properly but when i want save it in other formats i get A Generic error occured in GDI + exception its my code: Image Img = pictureBox1.Image; byte[] inputImage = new byte[Img.Width * Img.Height]; System.IO.MemoryStream ms = new System.IO.MemoryStream(); ms.Read(inputImage, 0, Img.Width * Img.Height); if (System.Drawing.Imaging.ImageFormat.Jpeg.Equals(Img.RawFormat)) { pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); } else if (System.Drawing.Imaging.ImageFormat.Gif.Equals(Img