|
if (control1.Bounds.IntersectsWith(control2.Bounds))
...
That should do it.
|
|
|
|
|
Hi =),
I have class that works with a Generic.Dictionary and now i want to access the elements by an index.
Is there a way i can do this ? ...or are there other classes where i can access the elements by an
index and provides the same functionality like the Generic.Dictionary?
I already found the Generic.SortedList, but there my listing will be sorted and i dont need/want that =/
|
|
|
|
|
Hello,
If you don't need the access per key functionality at, you should use an ArrayList. (System.Collections)
All the best,
Martin
|
|
|
|
|
Hi Martin, thx for the quick answer, but the ArrayList is useless for me cause i need the generic-properties.
I have a Generic.Dictionary that looks like this...
Dictionary<Guid, TcpClient> tcpConnections = new Dictionary<Guid, TcpClient>();
... and in some cases i want to access an element of the listing without to know the Guid, like this...
tcpConnections.Values[2]
... but unfortunatly this dont work
|
|
|
|
|
Ok,
And if you make a second Dictonary with 1, 2, 3, ... as key and access it like this.
tcpConnection2[1]
Hope it's not complietly stupid, but I have only .NET1.1 and never worked with Dictonary class before.
All the best,
Martin
|
|
|
|
|
I'ts not completely stupid, all youve done is make a second index for the list. Ive accomplished many tasks in this way.
Another way is with a collection that supports both key or index lookup - there used to be one in .NET 1.1 in the System.Collections.Specialized namespace. Im sure there will be a generic version in .NET 2
|
|
|
|
|
Hello,
Thanks for the info.
I think System.Collections.Specialized.NameValueCollection would be the .Net1.1 non generic version.
All the best,
Martin
|
|
|
|
|
The class System.Collections.ObjectModel.KeyedCollection provides the functionality you are looking for. However, you have to derive your own collection class from it, as you must override the GetKeyForItem member. Maybe it is suited for your application.
Regards,
Tim
|
|
|
|
|
yea your right , thx Tim
|
|
|
|
|
|
Martin
I believe that the reference should look like this:
[DllImport("user32.dll")]
public static extern int GetKeyboardLayoutList(int nBuff, ref int lpList);
Then, in your code, you would work with it like this:
int[] layouts = new int[1];
int length = GetKeyboardLayoutList(0, ref layouts[0]);
layouts = new int[length];
GetKeyboardLayoutList(layouts.Length, ref layouts[0]);
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello Pete,
It works!!!!
Thanks a lot.
Actually I made the mistake to define it as an array.
like this:
[DllImport("user32.dll")]
public static extern int GetKeyboardLayoutList(int nBuff, ref int[] lpList);
int[] layouts = new int[1];
int length = GetKeyboardLayoutList(0, ref layouts);
layouts = new int[length];
GetKeyboardLayoutList(layouts.Length, ref layouts);
This was strange because the first call of GetKeyboardLayoutList returned the write value (Lenght of 3).
But the second call, brought back a lenght of 1 with a value 0.
But with your help everything is fine now. (And it was not the first time of corse!)
So thank you very much again.
All the best,
Martin
|
|
|
|
|
When you create .NET UI objects on the fly, how do you handle the events that come to them?
Lets say that in code, I create any number of new buttons and put them on my form. How do I code a handler for the click event on those buttons? I won't know their names until they exist (Button1, Button2, Button3, etc), and I can't just have a huge list of
private void Button1(), private void button()
handlers sitting around in my code.
So, how do I code a handler for Button[x]? I'm sure there is something basic I'm missing here.
Thanks,
Joe
PS. I posted a much more specific version of this question in the .NET framework forum, before I realized that I had a much more general lack of understanding here.
|
|
|
|
|
In continuation with my answer in the .Net Framework forum
You could create a single event
Private void Button_Click(object sender, System.EventArgs e)
For each of the buttons you can assign the event handler as
Button1.Click += new System.EventHandler(Button_Click);<br />
Button2.Click += new System.EventHandler(Button_Click);<br />
Button3.Click += new System.EventHandler(Button_Click);<br />
.<br />
.<br />
ButtonN.Click += new System.EventHandler(Button_Click);
Based on the sender you can define what needs to be executed inside the Button_Click Event
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
|
|
|
|
|
Please see the following link:-
http://www.codeproject.com/useritems/DynamicServerControls.asp
It will help you.
Amit
|
|
|
|
|
Thanks everybody, for the fast and educated responses. I think I'm on my way.
Why is it that .NET, since it implemented a
toolstripmenuitem_DropDownItemClicked event, didn't also provide a
toolstripmenuitem_DropDownItemCheckedStateChanged ? This would have made this process much easier. I realize that not every DropDownItem will support CheckedStateChanged, but even giving me a general
toolstripmenuitem_DropDownItemTheresBeenAnEvent event, and telling me which event in the args, would have been better than nothing...
Thanks again! I'll be back... now that I know where you guys are.
|
|
|
|
|
Hi i am look for a Transparent control with Magnifier functionality just like a windows Magnifier component .i mean how i can make magnifying glass in c#.Net
thanks
-- modified at 4:45 Thursday 21st December, 2006
|
|
|
|
|
Hi All,
Its urgent
I am creating a word template Addinn. I am using "Word Template" project for that. My problem is how can create the set up for "Word Template" project. If any body knows then please help me.
Thanks in advance.
Amit
|
|
|
|
|
Hi,
can any body please help me regarding changing the fonts of any custom string placed any where in the custom control.
Thanks in advance,
regards.
|
|
|
|
|
You can place a string in a control. Either you assign the string to the Text or Caption property of the control, or of a Label that you add as a child control. To set the font of the text displayed, you change the Font property of the control where you put the string.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
hi,
can any body provide me with some help regarding the addition of a horizontal seperator in the context menu for .NET 1.1.
thanks in advance,
regards.
|
|
|
|
|
In the context menu designer, put a hyphen (-) in as the caption. This will be displayed as a separator.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello frenz,
In my application, I need to recreate & save an xml file frequently in a thread.
I use the Save() of the XmlDocument class to do this.
But at times, when I try to save the file, I get an WIn32IOError exception saying that the file is being used by another process..
Is it possible to check whether the file is being used by another program before saving?
If it is being used by another process, I need my application to wait until the resource is released to rewrite it.
Advance thanks for the help.
|
|
|
|
|
Try this..
File.GetLastAccessTime(@"C:\time.txt"); It will give last access time of the given file. If it is say within some given time limit, you can check it and then wait using Thread.Sleep().. and then continue..
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
u can use this logic as well
DateTime StartTime = DateTime.Now;<br />
while(true)<br />
{<br />
try<br />
{<br />
}<br />
catch<br />
{<br />
if(StartTime.AddSeconds(timeouttime) > DateTime.Now)<br />
{<br />
break;<br />
}<br />
System.Threading.Thread.Sleep(sleeptime);<br />
continue;<br />
}<br />
break;<br />
}
Regards
Shajeel
|
|
|
|