|
One way to do this is to copy only unique values into an ArrayList . If the size of the array list is < the size of the Values collection, you have duplicates. This seems the most efficient way (single-pass) to check for dupes.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Ravi Bhavnani wrote: One way to do this is to copy only unique values into an ArrayList. If
Or add all values as keys to another Hashtable That will save you quite a bit
|
|
|
|
|
leppie wrote: That will save you quite a bit
Hmmm, actually a Hashtable is more expensive than an ArrayList , so I don't see how it will save you anything, since you can make similar calls (i.e. Contains() vs. ContainsKey() ) to check for membership.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Ravi Bhavnani wrote: Hmmm, actually a Hashtable is more expensive than an ArrayList, so I don't see how it will save you anything, since you can make similar calls (i.e. Contains() vs. ContainsKey()) to check for membership.
Contains() for Hashtable is O(1) where ArrayList is O(n), also using the indexer of the Hashtable you dont have to check for the existaence of the key, you just overwrite it. This operation will take the same time as what adding each key to an ArrayList would be (excluding checking for duplicates), hence the Hashtable will be much faster.
|
|
|
|
|
What is the use of KeyStream and how it is used in hiding the message ???
AMAN ANWAR
|
|
|
|
|
|
I have a label with a trasparent background and a vertical scrolling bar. With the scrolling bar value, I set the top position (Y coordinate point) of the label to reposition it on scrolling event. When the scrolling begins, the form background flickers and it looks very goofy. Anybody have a solution for this problem?
|
|
|
|
|
If you're using .NET 2.0 you can try setting the DoubleBuffered property of the form to True.
If you're using .NET 1.x you will have to set this in the form's contructor manually using Form.SetControlStyle (I think that's the right method).
This might or might not work, chances are that you're moving the scroll-bar too fast for the computer to draw it flicker-free but using DoubleBuffering may help.
Ed
|
|
|
|
|
Changing RightToLeft works fine with most forms, but try it with a form displayed with ShowDialog() and it vanishes!
How to change the RightToLeft property of a modal form? I would settle for it vanishing if there was a way to get it back without losign any data (text box contents etc.).
Any ideas?
|
|
|
|
|
To answer my own post, I did find a solution of sorts - although it is a hack.
The form ceases to be modal if RTL changes and drops out to the next line of code. But it still exists and you can make it modal again, still preserving control data. These requires a loop and a means of breaking the loop. It's clunky, but I have not yet found another way.
Brian
|
|
|
|
|
Good question and after all this time, I fell into the same problem.. I didn't understand your workaround though, can you explain more?
Thanks mate!
|
|
|
|
|
this.RightToLeft = RightToLeft.Yes;
this.DialogResult = DialogResult.None;
Should do the trick!
|
|
|
|
|
Hello!!
Can I get the original string from a HashCode?
I mean, do the reverse action of GetHashCode.
thanks
Scan files and folders for viruses from your .Net applications - Click here!
|
|
|
|
|
I don't think that's possible. The hash code simply could not be unique enough to support all possible strings.
If you want to store string and hash code pairs, use a System.Collections.Generic.Dictionary<int, string> to store them together. You can then easily retrieve strings via dictionary[hashCode].
|
|
|
|
|
It's totally not possible. The hashing function is always one way.
Since int can only have about 2.2B possible values, there is way more than 2.2B possible string combinations.
|
|
|
|
|
|
No, it's not possible.
Just image if it was... You could put any data into a string and compress it to 32 bits. There would be no need for fast internet connections or large hard drives...
---
b { font-weight: normal; }
|
|
|
|
|
Hi all,
I tried develope my own version of the "Hooking Keyboard from IE".But the CBT hook proc is not working as expected.It is not informing abt the IE activation by setting the flag value.Only window creation is getting known. I am adding that code alone here. Please tell me where am i wrong in this.
public static int CbtHookProc(int nCode, IntPtr wParam,IntPtr lParam)
{
StringBuilder title = new StringBuilder();
string classname;
title.Capacity=10;
if(nCode==HCBT_ACTIVATE)
{
try{
GetClassName(wParam,title,10);
classname=title.ToString();
if(classname.StartsWith("IE"))
IE_Active=true;
else
IE_Active=false;
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}
}
return CallNextHookEx(CBTHook,nCode,wParam,lParam);
}
Please help me.
Thanks and regards,
LMHP
|
|
|
|
|
Hi all,
I tried develope my own version of the "Hooking Keyboard from IE".But the CBT hook proc is not working as expected.It is not informing abt the IE activation by setting the flag value.Only window creation is getting known. I am adding that code alone here. Please tell me where am i wrong in this.
public static int CbtHookProc(int nCode, IntPtr wParam,IntPtr lParam)
{
StringBuilder title = new StringBuilder();
string classname;
title.Capacity=10;
if(nCode==HCBT_ACTIVATE)
{
try{
GetClassName(wParam,title,10);
classname=title.ToString();
if(classname.StartsWith("IE"))
IE_Active=true;
else
IE_Active=false;
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}
}
return CallNextHookEx(CBTHook,nCode,wParam,lParam);
}
Please help me.
Thanks and regards,
LMHP
|
|
|
|
|
Hello
I done one grid view into this grid view i have one colum with dropdownlis but i don't know how get the var from this dropdownlist to my update function pleas help me.
good bye
best regards
|
|
|
|
|
Are you looking how to get selected value of dropdownlist?
Can you share your piece of code here, to see what is going on?
|
|
|
|
|
yes
<asp:templatefield headertext="Marks">
<itemtemplate>
<asp:dropdownlist datasource="<%#PopulateControls()%>" datatextfield="marks"
="" datavaluefield="marks" id="Ddl1" runat="server" backcolor="#FFFFC0" forecolor="MediumBlue">
c# code
public DataSet PopulateControls()
{
SqlConnection myConnection = new SqlConnection("Persist Security Info=False;Trusted_Connection=True;database=printer_order;server=(local)");
SqlDataAdapter ad = new SqlDataAdapter("SELECT [name_mark] as[marks] FROM printer_mark ",
myConnection);
DataSet ds = new DataSet();
ad.Fill(ds);
return ds;
}
-- modified at 10:49 Monday 10th April, 2006
|
|
|
|
|
The main problem is becaus i don't know what to give to @marks like parameter in create update down is a code for update command/
begin transaction
select @id_mark=id_mark from printer_mark where name_mark=@marks
if @@rowcount<>1 begin
rollback transaction
return
end
update printer_type
set name_type=@name_type,black_cartridge=@black_cartridge,color_cartridge=@color_cartridge,
discription=@discription,note=@note, id_mark=@id_mark where id_type=@id_type
if @@rowcount<>1 begin
rollback transaction
return
end
commit transaction
in all time is give me same error what to do?
Must declare the variable '@marks'.
-- modified at 10:39 Monday 10th April, 2006
|
|
|
|
|
i know to handle WinPrc() funzion, but how?
|
|
|
|
|
Derive a class from System.Windows.Forms.Form, and override the WndProc method.
As a side note, it's not a good idea to do custom drawing on the title bar. The title bar is maintained by the OS; in new versions of Windows, your app may not port well. In fact, Vista migration guidlines specifically mention that drawing on the title bar will be corrupted in Vista since the window manager composites how the title bar is blended with the background (as windows are translucent in Vista).
|
|
|
|