I have a panel that displays database information in labels (a lot of labels).
Now, the labels extend the size of the panel and you need to scroll down to see them all. Everything is working, and you can see the labels if you scroll down.
How do I print the form and the panel with all its content? I tried to capture the screen, but it's bigger than the screen.
Is there a function like panel.printAllContent().IntoAnA4Paper;?
I don't think that's the right way. As you said you display information taken from a database so you already have your data model. You should print the data, not the interface.
But, if you want to print the UI, I think you should first put the interface inside a Bitmap, and then print the Bitmap.
Here's a link with an example: http://www.codeproject.com/Answers/200887/How-to-print-part-of-the-window-form-in-c-window-a#answer4
Related
I'm trying to create an image matching game in C#.
My idea was to load all the pictures when I create the form. Then, when I launch the program and the form loads, I wanted to turn all those icons to black, hiding the pictures.
I've tried changing icon.BackColor = Color.Black but it doesn't do anything. Setting the visibility to hidden is also not an option.
Is there a way, or do I need to load the pictures individually using image.fromFile... went he form loads?
EDIT : As I was not able to find a way to answer this question, I took another approach. simply loading only black colored pictureboxes, attributing a random assigned name to each of them corresponding to an image. And on click, this image is shown.
As I was not able to find a way to answer this question, I took another approach. Simply loading only black-colored picture boxes, attributing a randomly assigned name to each of them corresponding to an image. And on click, this image is shown.
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.
In Activereports ver 7.0,
I have placed 2 textboxes one after another in vertical manner. I assigned particular width and height for both and then programmatically assigning text contents to both textboxes.
CanShrink property is set to true for both textboxes,so the textboxes can shrink to fit based on its contents.
My problem is once the first textbox shrink, I want to move the second one closely to the first one [To remove the extra space generated by shrinking], but it doesn't happen. Why is that?
Please check the image below
Because, the controls only move down, not up during report run. This is by design. In order to accomplish what you are doing, make the textbox1 size very small to begin with, so in essence it will always grow. In case if shrinks with not enough text you can use api to move the textbox2 up (use the location of that control in section format/before print event.
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´m using WinForms. I want to make a little class, which modifys controls to show it´s working.
I want to draw an overlay over for example a button. It should be a half-transparent gray.
After that i want to draw a ProgressBar on over it (in the center). Similar to This, except using a progress bar.
How can i realize this? I don´t want to set the position of the progressbar, just drawing it on the other one.
How could i do this?
Thanks :)
I have done something similar before.
You need to use Button.DrawToBitmap(Bitmap, Rectangle) to get the image of the button. Then make the Bitmap grayscale (there are multiple algorithms available for this; I have used the last one successfully although probably not originally from this site).
Now, I did this with an entire form instead of a button, but I disabled the form, and then covered the entire form with an image of itself, altered and then covered it with the progress bar (itself in a panel with other controls).
You could just as easily disable the button, cover it with a panel containing the image and the progress bar on top of it.