Ok so I am trying to do something extremely simple but its turning out to be extremely complicated. I wanted to be able to select my text for all of my labels. Since you can't do that I had to convert them all to textbox's. Now that I have that done I want the user to be able to drag their mouse across an area on the form and select whatever text they roll over. A good example would be a web browser.
EDIT
Ok I need to make this a little more clear and what better than some imagery.
Look at the picture above. I cannot drag my mouse across the form to select the text. I have to click inside the TextBox and then I can only select the data that is inside that specific field. I just want to be able to click and drag my mouse over whatever textbox is in my area of selection.
have you "set its BorderStyle to none and set the background color to the color of your form. Also don't forget to set the readonly property to false"
from http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5ac4267d-2642-4d05-ae84-1562bf16d068/
Related
I've been trying to get to make the whole area clickable, in the picture you can see the size of the linklabel, but only text is clickable, I want to make the background of the link label(the whole area) clickable too, is that possible? How can I do that?
I've tried using
linklabel.LinkArea = new LinkArea();
But it only works for the text that i have. I've checked out StackOverflow Posts such as this or this but i couldn't get something out of it.
You can use a panel, with a mouseclick event on it, after that you can add a label or whatever you want
Panel
I am making an interface where on the left is a column of menu buttons.
A couple of the buttons bring different graphs (each on it's own panel) to the front to view, using the BringToFront() method. I also have a "Save image" button where you can save the graph.
How do I setup the button to save whichever panel is in the front? Is it better practice to use "Enable/Disable" instead of BringToFront and then save whichever panel is enabled?
Previously, I had all these panels within a TabControl, and I had the button save the graph on whichever tab was selected, but I got rid of the tabs because I did not like the way it looked.
Thanks in advance.
The most easiest way is to store the actual active image in a variable, changing it's value by clicking the buttons. If you store the image itself or just the index or whatever to determine which image is actually infront is on your choice.
Another aproach could be, show and hide your panels, then you can iterate over your panel list and check which panel is not hidden.
In my code I have some pictureboxes that are clicked onto a panel by the user. Wherever the user clicks a picture box is placed. The location is stored in a database so that it can be called back later.
When a user clicks a picturebox it changes the backcolor property to red to give the impression of it being highlighted.
My issue is I want to add a groupbox (or another method of surrounding) around the highlighted boxes. So a user clicks say 4 picture boxes and clicks "Surround" button and it draws a groupbox around those 4 pb's. But I am at a loss since I don't know how to get the location of the outer pictureboxes (the ones that the group needs to surround) since they are all done on the fly?
Any advice would be great.
You probably have the list of all pictureboxes in your application somewhere (if you place them inside a container, that would be Children property). I suggest you simple foreach through all picture boxes and find min/max coordinates, and from there you can easily get the coordinates for the surrounding box. You might be able to do all that using one LINQ query.
Hello,
Above is the program I am writing. On the right panel is basically two custom controls (the blue rectangle area) I created and just added them as controls to the background panel control when this winform program loads.
I used MS paint to draw out the pop up balloon that I want to see when my mouse enter this control's area. I want to do the following:
1. If mouse enter the control area, the yellow area balloon pop up and populate with the information of that specific control
2. If mouse move out of the control area, the pop up balloon disappear.
Can this be done with Winform application? I looked around and found out about Tooltip class but so far from researching I don't know if it does what I want to do.
I could be wrong but googling around gave me the impress that Tooltip offers very little in term of style. Ideally I want to make this pop up balloon into almost like a border-less pop up window where I can put image , font ect.....at will. Also Tooltip works if you hover over a button or specific field whereas I want the entire control area.
Can this be done? I appreciate if you can point me to any work around if there is one.
I wrote a comment, but I figure I'll expand it into a full answer. This is assuming you want a new control, which isn't a tooltip, for maximum customizability. I did something similar to this for work recently, to act as a non-modal info popup that disappears when clicked.
Creating a Custom Popup Form
What you want is essentially a floating popup that appears over your form, which means you'll want to define a new Form object, rather than a UserControl, as it won't actually be embedded within your other form.
Give it a multiline, non-editable textbox that you can fill with the information you want to populate, then simply call a new instance of the form on your Mouse_Enter event. Close it upon Mouse_Leave.
Adjusting The Style
You'll have to play with it a bit to get it to actually act like a popup and not just a window. I'd recommend setting it to a non-modal popup, and removing the border. You can write a function to automatically size it to its contents. I don't imagine you'll want the user manually resizing it.
Some other things to look into would be overriding the CreateParams property that comes with the basic Form object. You can force DropShadows and TopMost forms without making the form modal. Overriding ShowWithoutActivation to always return true will prevent the form from stealing focus when it pops up.
I'm not sure if you can pull off rounded edges like you have in your mockup. Perhaps you can pull it off with some wizardry in the OnPaint() function, but I couldn't tell you how to do it.
It might be a bit of a pain for fiddling around with, but you can get some good functionality and appearance out of it. If you think you can pull it off acceptably with the ToolTip class, go for it. It took me about a week to get my notifications where I wanted them (though I added several features that you probably don't need to worry about).
Examples
Some keywords to look up in related searches would be Toast Notification and Non-Modal Popup. This might be some use:
http://www.codeproject.com/Articles/442983/Android-Style-Toast-Notification-for-NET
Since you already have implemented custom user controls you might want to try it again. Make a control that is that style and color, changes it's size based on it's text. You can feed it information (such as the text to display) from your existing user control object. You can also have the mouse enter/leave code reside in your first user control.
If you're not sure how to make a rectangle with round corners you can either make it on the fly using a graphics object (which will turn into a bitmap on the screen) or make it how you want it to look in GIMP (or photoshop if you have it) then use that image as the background on your user control. Make the default background transparent (so your voids above the round corners are not grey). If you make a pre loaded image you'll need to be aware you will only be able to scale it equally in Y and X directions. unequal scaling will make it look distorted.
Can you use the Mouse_Enter event on the control?
I have a view and within the view, there are two user control, each with a button on it. When the page loads, the first user control will load. when i click on the button in the first user control, I would like to slide the first user control left, making it invisible and display the second user control. when i click on the button in the second user control, I would like to slide the second user control right, making it invisible and displaying the first user control again. can anyone help on how to achieve this?
If I get correctly, you want something like Carousel in wpf. In case that's it, here's the link. It allows you to slide several items left-right to switch between them.
Another way to go would be using default animations in WPF, meaning DoubleAnimation applied to Margin property that increases margin from 0 to 500 (to move it off the screen) and back to 0 (to return it) or something like that. Head's up for double animation and moving controls is here and official documentation here.
Rather than hard-code an animation designed for your specific scenario, you could do something a little more generic and adapt the TransitionControl that uses pixel shaders. Set the content property and you can specify which shader effect you want it to apply as the transition.