|
swo.priv wrote: hat would be an ideal way to do it, if the MouseEventArgs contained data related to the link that was under it. Also, the MouseHover event uses EventArgs, anyway.
Why is this a problem? You know which LinkLabel you are in because MouseHover tells you in the "sender" param - all you have to do is cast it to a LinkLabel or derivative:
LinkLabel l = sender as LinkLabel;
if (ll != null)
{
...
} or
ProtLL pll = sender as ProtLL;
if (pll != null)
{
...
} You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
A LinkLabel can contain a string of text, broken in to several links, within a single LinkLabel control. I'm trying to get the link that is hovered, not which LinkLabel.
For example, a string could be "the quick brown fox." That could be broken in to links. "The quick" could be a link by itself, "brown" could be a second link and "fox" could be a third link. All three links can be inside the same LinkLabel. The problem is getting which link is being hovered.
This is why I'm trying to get access to the PointInLink(). The equivalent for a ListView is GetItemAt(). An example using the ListView version would be:
Point p = lv.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y));
ListViewItem lvi = lv.GetItemAt(p.X, p.Y);
What I need is the LinkLabel version of that. Another solution would be if I could get the hovered state of a link, run my links through a loop checking their states, and return the hovered one, but I cannot find a way to do that, either.
|
|
|
|
|
Yes. So?
private void linkLabel1_MouseHover(object sender, EventArgs e)
{
ProtLL pll = sender as ProtLL;
if (pll != null)
{
Point p = pll.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y));
System.Windows.Forms.LinkLabel.Link l = pll.GetLink(p.X, p.Y);
}
}
I assume you are using your ProtLL class instead on LinkLabels on your form? Otherwise, no, you can't access it. If you only have the one ProtLL you are interested in, then use it's name directly instead of casting it.You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I could have sworn I tested exactly what you said and it didn't work (as indicated previous).
You provoked me in to setting up my test again and this time it did work. I must have overlooked something in my old test.
Thank you so much! I truly appreciate it!
|
|
|
|
|
|
Where are you defining the length of "count"? CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I have a data application that is using a DataSet via the designer.
I'm trying to create a form that binds data from one table "MyData". One of the fields "picker_fk" uses an FK relationship to a second table "Picker". "Picker" has only one field in it called "descript" (not null, unique).
In the form, I set up the DataGridView to use the DataSet.MyData table. For the combo box column, I set the following properties:
DataPropertyName = "picker_fk"
DataSource = bndPicker (a binding source that uses the "Picker" table from the DataSet)
DisplayMember = "descript"
ValueMember = "descript"
This is all good until I create a new row, select a value from the combo box, and then move focus away. I get a message:
SystemArgumentException: Column "descript" is not belong to table "Picker".
What's up with that? I'm looking right at the field in the DataSetDesigner. "descript" is the ONE AND ONLY field in "Picker". How can the debugger say it's not in there?
I dug around and found a suggestion that this error could occur with data type mismatches. But I have verified that both Picker.descript and the referencing MyData.picker_fk are both of type System.String.
Does anyone have any ideas?
|
|
|
|
|
Never mind. I found it. The error message is actually misleading because it doesn't have to do with the names. It has to do with the sequence in which databinding takes place. I set up the BindingSource for the grid BEFORE the BindingSource for the ComboBox options. It's odd that this error was not detected right away but only after adding a row, but I'm not the only one to experience this:
http://adamhouldsworth.blogspot.com/2009_04_01_archive.html[^] (Scroll down to the 7 April 2009 entry "Data Binding Pitfall").
|
|
|
|
|
What is the format needed for Intellisense to pick up on my comments for my enums? So when I type “MyEnum.ItemOne” the intellisense will display the documentation I’ve written for “ItemOne”?
Also, is there some sort of command I can use in Visual Studio that will generate a compile error if I don’t use all possible Enum values in a switch statement? I’m looking for a compile-time dummy catch incase I add an extra Enum value later but might miss a statement that should switch on all possible values of the Enum.
Thanks!
|
|
|
|
|
public enum Blah
{
Terror,
Nitro
}
[Edit]Fixed "<" signs
For Point 2: Not that I know of.
But It shouldn't be too hard to create a method that checks each enumeration used.
[/Edit]
|
|
|
|
|
Thanks, works perfectly! I was trying variations on
public enum MyEnum
{
ItemOne
}
with no success =/
|
|
|
|
|
what the System.Terror?
It sure does. If you mess with it you're f... modified on Friday, March 5, 2010 6:33 PM
|
|
|
|
|
Anticast wrote: a compile error if I don’t use all possible Enum values
nope.
you could come up with extra code that performs some checks, but it isn't straightforward.
|
|
|
|
|
If you use "tab tab" for the switch it will automatically put in all cases
|
|
|
|
|
that's a good one. i had no ideea. thanks
|
|
|
|
|
I didn't know this until recently, when I did it by accident - imagine the chances of that happening !
|
|
|
|
|
cool
|
|
|
|
|
I agree, thanks for the tip!
|
|
|
|
|
I had no idea! Real cool! -Bryan
My latest programming adventure was coding the multimedia features for the Rip Ride Rockit coaster at Universal Studios Florida. I love my job.
|
|
|
|
|
You may want to check out GhostDoc[^]
It is a free add on for Visual Studio that makes documenting stuff (for Intellisense or not) realy easy.
Ctl+Shift+d while the insertion point is in your enum and all of the ///<summary></summary> tags for each option are inserted (and the stuff at the top).
I am a bit of a fan since I found it.
|
|
|
|
|
Putting all enums in a switch statement simply because they exist is pointless. There are MANY times when you simply don't care about 1 or more of the ordinals (lumping their handling into the default: clause)..45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi,
i am trying to write a title to an image and save it back to its current location but i am having a problem as the following message is being thrown:
A generic error occured in GDI+
A first chance exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
System.Drawing
A first chance exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
System.Drawing
Error code: -2147467259
" at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)\r\n
at System.Drawing.Image.Save(String filename, ImageFormat format)\r\n at ZooSystem.ImageViewer.ApplyChanges()
in E:\\ZooSystem\\\ImageViewer.cs:line 520"
I have checked the permissions for each of the images in the folder and they all have FullControl/Read/Write/Modify permissions but the folder has "Read-Only" enabled.
The folder was created on the Internal Hard drive of the computer and I am using Windows Vista Home Premium 32-bit. I am using MS VS 2008 Pro edition which i run in Admin mode.
If i save the images to another folder say one of the Public folders then the above exception is not thrown.
But I would like to save my images to the same folder if possible?
How could i go about doing this? I would appreciate if somebody could help me with the above. I have been trying to fix it for past 2 hours.
Thanks,
Here is the code i am using:
private void ApplyChanges()
{
if(txtBoxOut.Text.Equals("")
{
if(sfd.ShowDialog()==DialogResult.OK)
{
this.SaveTheImage(sfd.FileName,this.bmp);
}
}
else if(txtBoxOut.Text != "")
{
string destFolder = txtBoxOut.text
foreach(string filePath in filePaths)
{
this.bmp = Image.FromFile(filePath);
string fileName = Path.GetFileName(filePath);
try
{
if(destFolder.EndsWith("\\")
{
this.bmp.Save(destFolder+fileName+ImageFormat.Jpeg);
}
else
{
this.bmp.Save(destFolder+"\\"+fileName+ImageFormat.Jpeg);
}
}
catch(Exception e)
{
Console.WriteLine(e.message.ToString());
}
}
}
}
|
|
|
|
|
Most, if not all, errors inside GDI+ are reported as "generic problem occurred in GDI+". If the affected line is an Image.Save chances are your path is incorrect or inaccessible, your disk is full, or your destination file exists and is locked.
If you load an image from a file, most of the time the file remains locked as long as the Image is alive. This would prevent you from saving an image to the same path.
It applies to Image.FromFile, and probably also to PictureBox.ImageLocation
The one exception I am aware of is when you use Image.FromStream.
So I suggest one of these two workarounds:
Bitmap bm=null;
{
Bitmap bm1=Image.FromFile(filepath);
bm=new Bitmap(bm1);
bm1.Dispose();
}
or
Bitmap bm=null;
using (FileStream stream=File.OpenRead("image.jpeg")) {
bm=Image.FromStream(stream);
}
|
|
|
|
|
According to Documentation[^]
"You must keep the stream open for the lifetime of the Image." so should not the second snippet throw an exception?
|
|
|
|
|
Hi Giorgi,
Thanks. I missed that line in the documentation, and no it has never thrown me an Exception; AFAIK once the pixels are loaded, file (and now also the stream) access is needed only when extra information is asked for, (e.g.the JPEG tags), which I don't ask for unless I use Image.FromFile().
Theoretically I now must change my standard reply to always create a copy of the first image, then dispose of it. Grr.
|
|
|
|