|
Hello,
My code is trying to delete IExplorer history from the registry! The typed URLs are stored in a checked listbox, i can delete one value at a time both in the registry and from the checked listbox but when i try deleting multiple items at a time it doesn't work? here is the code
private void Delete_Click(object sender, EventArgs e)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\TypedURLs", true);
string[] v = key.GetValueNames();
string[] t = new string[v.Length];
int count = checkedListBox1.Items.Count;
for (int i = 0; i < v.Length - 1; i++)
{
t[i] = (string)key.GetValue(v[i]);
if(t[i] == (string)checkedListBox1.SelectedItem)
{
key.DeleteValue(v[i]);
}
}
for ( int i = count; i > 0; i--)
{
if (checkedListBox1.CheckedItems.Contains(checkedListBox1.Items[i - 1]))
{
checkedListBox1.Items.RemoveAt(i - 1);
}
}
}
|
|
|
|
|
Hi,
if(t[i] == (string)checkedListBox1.SelectedItem)
SelectedItem is one item, use SelectedItems to get all selected items:
if (checkedListBox1.SelectedItems.Contains(t[i]))
Add also this in the constructor:
checkedListBox1.SelectionMode = SelectionMode.MultiExtended;
checkedListBox1.SelectionMode = SelectionMode.MultiSimple;
Hope this helps.
In some cases, my signature will be longer than my message...
<em style="color:red"> <b>ProgramFOX</b></em> ProgramFOX
modified 14-Jan-13 11:57am.
|
|
|
|
|
Still doesn't seem to have worked? Any other ideas please?
|
|
|
|
|
Erol2309 wrote: Any other ideas please?
I updated my answer.
In some cases, my signature will be longer than my message...
<em style="color:red"> <b>ProgramFOX</b></em> ProgramFOX
|
|
|
|
|
What does "doesn't work" mean? Ate you getting exceptions? What happens when you step over the code?
|
|
|
|
|
Well it means that when there are all the items in the checkedlistbox selected and i press the delete button they get deleted from the checkedlistbox but not from the registry...i cand only delete values from the registry one at a time and only when there are more than 2 entries..
|
|
|
|
|
I Checked your code for deleting the multiple items from the registry and it works fine, if doesnt work means check the checkbox comparison operations.
Also I doubt on the action performed inside the second for loop, the checkBox content is checked against its own value was it v[i] or t[i] arrays?
Jibesh V P
|
|
|
|
|
If you had stepped over your code, you would have seen what the problem is. Basically, you're iterating over one list of values, and you're getting one single value from the other list to compare it to. Try iterating over the selected items from the list box as well, and do your comparison in there.
Now, a more important point is that your comparison code is using terrible variable names. I ended up getting confused by your t and v variables.
|
|
|
|
|
Hi,
I am trying to trite a small app that acceses internet browser history on IExplorer using its registry. Somehow i cannot delete the URLs that have been viewed.
note: After accesing the registry i store the data in a checkedlistbox. Any help?
private void Delete_Click(object sender, EventArgs e)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\TypedURLs", true);
string[] v = key.GetValueNames();
string[] t = new string[v.Length];
int count = checkedListBox1.Items.Count;
for (int i = 0; i < v.Length - 1; i--)
{
t[i] = (string)key.GetValue(v[i]);
if(t[i] == (string)checkedListBox1.SelectedItem)
{
key.DeleteValue(t[i]);
}
}
for ( int i = count; i > 0; i--)
{
if (checkedListBox1.CheckedItems.Contains(checkedListBox1.Items[i - 1]))
{
checkedListBox1.Items.RemoveAt(i - 1);
}
}
|
|
|
|
|
Um:
for (int i = 0; i < v.Length - 1; i--)
{
t[i] = (string)key.GetValue(v[i]);
i-- ? Really?
We all do it at some point...
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
wow....that was just to stupid....sorry...thanks alot!!! I really apreciate
|
|
|
|
|
As I said - we've all done it!
(I tend to read what I meant to write which doesn't help... )
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
I think it was nearly OK before -- I find removing items from a list in reverse is easier -- but you would need to use
for ( int i = count<big>-1</big>; i ><big>=</big> 0; i--)
|
|
|
|
|
Hello
I am trying to use a method that reads all the values from a subkey but something seems to be wrong...can anyone tell me the corect way to do it?
<pre lang="c#">public string[] ReadValues(string rkey)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(rkey);
string[] VNames = key.GetValueNames();
string[][] values = new string[VNames.Length][];
string[] v = new string[VNames.Length];
for (int i = 0; i < VNames[i].Length; i++)
{
values[i][0] = VNames[i];
values[i][1] = (string)key.GetValue(VNames[i]);
v[i] = values[i][1];
}
return v;
}
|
|
|
|
|
this is one of the easiest exceptions can be resolved by debugging your application. put a break point at this line
RegistryKey key = Registry.CurrentUser.OpenSubKey(rkey);
and debug your application.
most possible case is key or VNames variable is be null.
Jibesh V P
|
|
|
|
|
i am building an online based Examination project using asp.net, when the student click an option the option should be stored into database, and if the student which to edit the answer, he or she should be able to do click previous button and edit it.
|
|
|
|
|
Very good. I'm delighted for you. I am so pleased that I am going to have to have a lie down now.
|
|
|
|
|
...and the question would be ...... ???
|
|
|
|
|
The question is what the question is!
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
What is the sound of one neuron firing?
|
|
|
|
|
Is there a way to tell the binary reader how many characters to read because i need the code to read certain amount of bytes in every row of the code and this code i want to read the first row i need to read only 10 Bytes and not the whole row
this is a part of the code that reads from the file
string emriK = brHuazimet.ReadString();
now i know how to write this string into the file i am going to write after reading this part but when i try to read it reads to much from the code
If u need any more explanation let me know
|
|
|
|
|
Yes its possible to read selected no of byte. Use the Read method instead of ReadString. check
here for Read Syntax[^]
/Edit Sorry I dont know what happend I just updated the link path again
Jibesh V P
modified 13-Jan-13 0:45am.
|
|
|
|
|
there is nothing in that link :S
|
|
|
|
|
Try this.[^]
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
hi guys . i have many client that are connected to the server .
i can connect to the server completely with out any wrong in my code from my clients .
and the server response the client pretty fine .
okay , what do i need to do , is that if one client send some data to the server , i need the server to response to all the clients . like
Server/Client []
now the server just can respond the client that send the data .
any help i'll be greatfull.
i hope you got what i mean .
modified 12-Jan-13 13:57pm.
|
|
|
|