|
Sorry about that...my mistake. The code should have been:
public void doImage(object source, ImageClickEventArgs e)
{
ImageButton ib = source as ImageButton;
if (ib != null)
{
switch (ib.ID)
{
case "IB1":
Response.Redirect("ibtest.aspx");
break;
case "IB2":
Response.Redirect("another.aspx");
break;
case "IB3":
Response.Redirect("third.aspx");
break;
}
}
}
|
|
|
|
|
I done as your code of you and it compiled sucessfully.Scott Dorman, thank you so much.
nothing
|
|
|
|
|
You're welcome. Glad you got it working.
|
|
|
|
|
Hello Scott,
Scott Dorman wrote: ImageButton ib = source as ImageButton; if (ib != null) { switch (Source.ID)
I think you also wanted to use the casted ImageButton instance for the switch.
All the best,
Martin
|
|
|
|
|
I'm sorry I have to keep coming back to the community about this... but I find NOTHING o google or in the books about icons. (I've looked a lot, speeking to Christian Graus and Undefeated, and whoever else). I honeslty just can't get an icon to appear (or atleast the one I made). Do you have to add it by code, or just from the form designer? I've tried mainly the form.
Please help, it's just been bugging e to get it to work. (and if anyone has any tips they'd like to share on Cursor files...)
Thanks in advance and thanks agian for all the great tips from the community, though I still act dumb/stubborn sometimes.
|
|
|
|
|
If anyone's tired of hearing me yap, I just figured out an odd way to make an icon, but it's wrong. I'd still really appreciate it if anyone would help on the right way. Please, and thanks again.
|
|
|
|
|
Hi,
two comments:
1.
an icon file can hold multiple icons (icons at different sizes), and Windows will pick one
depending on circumstances, so if they do not all look alike, you may get very confused.
2.
I tend to create icons programmatically; the following code converts a (best small, square)
image into a simple icon:
string filename=popupNode.getLongName();
try {
Bitmap bm=(Bitmap)Image.FromFile(filename);
if(bm.Width!=32 || bm.Height!=32) {
bm=new Bitmap(bm, 32, 32);
}
Icon icon=Icon.FromHandle(bm.GetHicon());
bm.Dispose();
string filename2=Path.ChangeExtension(filename, ".ico");
Stream stream=new FileStream(filename2, FileMode.Create);
icon.Save(stream);
env.output("Created icon "+filename2);
} catch(Exception exc) {
env.output("Failed to create icon from "+filename);
env.log(exc);
}
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Is there anything extra in the 'using' end of this? To use the icon, I mean?
|
|
|
|
|
As I have told you before, it all can be done with Visual Designer:
- application icon (for Explorer, task bar,...) = project property
- form icon (top left corner) = Form.Icon property
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Okay, thanks! finallllly
|
|
|
|
|
You're welcome.
Don't understand how a single Icon can keep you puzzled for a week now[^]!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
hello, thanks in advance for your precious time.
i have a datagridview which has its datasource from a certain dataset ,
how can i updata that certain dataset with the new rows / values which the user is alowed to add to datagridview ( update the dataset with all the changes that have been done to the datagridview).?
Net
|
|
|
|
|
I have a comma delimited text file that I am trying to import into SQL on the fly.
For the sake of discussion, the file would be formatted like this;
yyyy/MM/dd HH:mm:ss,022.514.045,Site Name,TX,0000,0000,Alarm Name,ON
File name RWALARMSyyyyMMdd.txt
I understand how to monitor a directory with FSW, not the contents of a file.
Any suggestions would be greatly appreciated.
Thanks,
|
|
|
|
|
I assume an outside process is appending to this file and you want to then import that new information to SQL?
The FSW will of course tell you the file has changed. You will then need to verify that outside process has completed using the file. You do this by attempting to open the file for writing and only proceed when you have an exclusive lock on the file.
Now at this point, there are a few ways to do it (your choice depends on how you exactly get the data), but I will describe what I found to be the easiest for me. If it's the first time opening a file just import the entire contents into SQL and then I will write a comment line that is the timestamp of when I imported that batch (ie. # MM/dd/yyyy HH:mm:ss (# of records) imported)
So I know the next time the FSW kicks off my process, I just jump to the last comment marker I wrote to the file and ready everything appended after that.
Another option is to get the last record date from SQL and only read the records from the file with a greater date. If your text file isn't sequential, this approach could add more code to sort the file by date or another approach.
You could also create an import table in the database that has the timestamp and the line number offset from the previous import and use that number to jump within the text file.
Hope I've given you some ideas on how you can approach the file importing.
Also, just in case I misunderstood and you wanted code specific stuff and not appracoh opinions then look into the TextReader and TextWriter classes, along with ADO.NET
|
|
|
|
|
Yes, you assumption is correct.
A program that was written by someone else, writes a log entry each time a piece of equipment has a failure or clears the failure.
There is no file locks on the file, and I can manually edit it as necessary.
The system opens a new file @ midnight each night, so that would be the first time it is opened.
I didn't mention it, but I envision this as a Windows Service so that it will be done automatically.
Yes, I am looking for some code assistance. I can do the SQL piece, I am just not firmiliar with the FSE for monitoring changes to the contents of a file.
Thanks,
|
|
|
|
|
Hi,
Can anyone help me with editing the key's Name/Type/Data fields.
I can Edit the Data with SetValue() from Microsoft.Win32 namespace.
But how to I go about Changing the Type and editing the Name.
I have posted this qn with wrong name, so posting again.
|
|
|
|
|
You can't directly change the type or the name of the key. In order to do this, you will need to create a new key with the correct name and type, copy the data from the old key, and then delete the old key.
|
|
|
|
|
Hi Scott,
Thanks for the reply! My task is not to change/edit the key, but the Name/Type/Data of the key. Its like creating how to create new string value, DWORD value, Binary Value etc.
D
|
|
|
|
|
Dino2Dino wrote: My task is not to change/edit the key, but the Name/Type/Data of the key
Right, I understood that. The problem is that once a key is created, it's data type cannot be changed and, as far as I know, it's name cannot be changed either. In order to make those types of changes, you must create a new key, copy the data, and then delete the old key. There may be some underlying Win32 APIs you could call using P/Invoke, but I don't know of any off hand.
|
|
|
|
|
Thanks a lot Scott! I will check on the APIs.
Thanks again!
D
|
|
|
|
|
Scott is correct. There are not API functions to rename a key or value or change a value type. If you want to rename a key or value, you have to create the new key or value with the correct name and copy the data from the old key/value to the new one, then delete the old one.
The same is true if you want to change the value's type. In this case, though, you can't create a value with the same name, so you have to read the data into a buffer, delete the value, then create the name value with the same name, but different type, then CONVERT THE DATA to the new type and write the new value with it. That conversion is going to give you a headache. Some types just don't convert to others.
|
|
|
|
|
Hello,
Thanks for the answer.
However I am afraid I didnt understand it completely.
If HKEY_CURRENT_CONFIG\Software Has
Key Name Type Data
Font LogPixels REG_DWORD 0X00000
In this case, My task is to edit the Name LogPixels or Type REG_DWORD or Data0X00(This can be done through SetValue).
AFAIU, If I have the Name/Type/Data into some buffer, I can delete the Key(Font) and create it again with new name.
However, I didnt understand, what if I wanted to edit LogPixels? I cannot use DeleteSubKey or CreateSubkey to modify the Name Field. How can I create the new Name?
Please Clarify!!!
D
|
|
|
|
|
In the registry, KEYS are the containers that hold VALUEs. In RegEdit, all the keys are the little yellow folders in the tree on the left. All the values under the selected key show up on the right.
We've described it as simply as possible. There is no such thing as renaming a key or value.
It's no different that if you were creating a new Value from scratch. You cache the data, delete the old value, create the new value with the new name and give it the cached data using SetValue().
|
|
|
|
|
Hii Dave,
Thanks for the clarification!Appreciate your help!
D
|
|
|
|
|
I answered this question last week and gave you the exact same information that the replies in this thread say. Did you even try?
|
|
|
|
|