WinForms TreeView Display positioning - winforms

I have a TreeView (System.Windows.Forms.TreeView) control on a custom control (similar to the Output window in visual studio 2013). that control is placed at the bottom of a main form (like the visual studio ide). when i populate this TreeView control with data, it fills correctly, but, if the containing control is close to the bottom, the displayed "popup" is cut off. if i expand the lower control to have more room, the control displays with all the data. the display is "docked" to where it was designed. i tried putting a scrollbar on the display (which worked), but this is not the desired/requested behavior.
what i would like to do is to either have the display "go up", if necessary, like the "Show output from:" display on the Output window in Visual Studio 2013, or, simply have the display be FreeFloating.
any suggestions would be greatly appreciated.
thanks in advance.
pete.

RESOLVED:
- create 3 new variables ... originalParent, originalLocation, and firstTime.
- in the Resize method (which is called from a mouseOver event), where the size of the display is set, if this is the first time, save off the above and set the parent to the TopLevelControl
- determine the new location on the form ... originalParent.FindForm().PointToClient(originalParent.PointToScreen(originalLocation).
- see if the displayed output would go beyond the end of the top form ... TopLevelControl.DisplayRectangle.Height - (locationOnForm.Y + oTreeView.DisplayRectangle.Height)
- if the difference is less than 0, adjust the new location.Y by the difference.
- set the display output Location to the new location
presto ...
also, added a method so that when the main form is resized, or the containing control is repositioned, the location is set using the info above - just not adjusting for the display output height.
add a call to the reset in the mouseLeave event

Related

Combo box in a MFC application

My question is about combo boxes in Windows MFC applications.
The dropdown part of the combo box contains items composed of a bitmap and a string.
Sometimes, the strings are too long and I have to adjust the width of the dropdown part of the combo box using the CComboBox::SetDroppedWidth() method.
My problem is that when the combo box is near the right edge of the computer screen, the right part of the dropdown is hidden (see image_1 and image_2 below).
I would like it to behave like in Excel (see image_3 below) meaning I would like the dropdown list to be shifted accordingly so that all its items can be seen without being cropped.
How can this be achieved?
image_1: right part of the dropdown is NOT hidden
image_2: near the computer right edge, the right part of the dropdown is hidden
image_3: Excel combo box
=================================================================
EDIT 1
=================================================================
EDIT 2
Ok. I forgot to mention that m_cbXmodels is a CComboBoxEx object. This is why the handles are NULL. I could get the handles via GetComboBoxCtrl()...
Handle the CBN_DROPDOWN notification.
Get the handle for the list control with GetComboBoxInfo.
Now use MoveWindow to adjust the window as needed.
Getting the current screen size is available with MonitorFromWindow. See rcWork member in MONITORINFO. You just need to adjust the left and right coordinates.
EDIT: As you can read in the comments: My Approach with CBN_DROPDOWN is to early Thanks to zett42). It is not possible to resize the combo box list part here.
But it is possible to post a user defined message to the same window and to reposition the window than.

Reportviewer: Unable to set Interactive height to 0

I am using reportviewer 2010 Winforms
In normal mode, I want the entire report to display in one page only. I read different topics and learnt setting the Interactive height property to zero might do the trick.
I believe I could set the INterative height by clicking on a tablix -> In Properties window, there's a Size which has Width and height. However when I set the height to 0, it reverts back to the previous inches which was there before.
I need help with how to set the Interactive page height? Is this set at report level or for each tablix inside the report?
I believe the width and height setting in Report => Report properties is for physical rendering (PDf) and not for logical rendering (Html in normal mode).
Thanks in advance.
Nevermind, I was able to figure it out. I had to bring up the Report properties by clicking somewhere outside the report in the rdlc file. In the properties, I was able to find Interactiveheight and I set it to 0.

How to Move content to next page in WPF Form

I am new in WPF if there is something wrong please co-operate.Here i require some idea from experts.
I am working on one application in which i have to show some content on WPF form after filling the fields present on the form.On the same form i also have a print option.
Check this image.This is my form here part in the red block is generated at runtime.When i click on the print button it only show the visible part on the paper and skip the remaining part.
Problem :
How i can move the remaining part of the form which is under scroll to next page when i click on print.
For example in the given image we can see only 2 bulls eye completely and next 2 partially.How i can shift this remaining part to next page only when i click on print.
The answer is quite easy : don't rely on your window to do the printing, but build the visual you want then print it.
For instance, you must have a function that creates dynamically the circles and so on, then adds them to a Panel. What you might do is to print the Panel.
Or if you prefer, you might build Dynamically a new window, where you put all the Data you want printed as you want, then print the window. The advantage of this method is that it is more flexible for the content (if you want a header/footer) and also you can watch the content easily for debug. Note that even if the Window content is dynamic, you can have a base window for printing that avoids you to do too much xaml with code (expl : you might have TextBox bound to a PrintTitle property that you setup in the constructor of the Print Window...).
Notice that visual that were not rendered on screen will not print. Be sure, to avoid the common issues, to have a look at this article from this great site, switch on the code, here :
http://www.switchonthecode.com/tutorials/printing-in-wpf
Edit (reply to the question in comment):
1) If you have fixed number of bulls eyes, just make one Window for that number and Print it, this is waaaay easier.
2) To put Visuals in pages instead of rows, you'll have to rely on page Width/Height. What matters is the size of your control vs size of page. In the example, they build (in OnRender) Controls having LineHeight, LineWidth as size. Do the same : Try to put as many line of control as you can such as
(Control Height + margin )*NumberOfControlPerPage < Page Height.
Then you have to change OnRender to render controls instead of Rows made with rectangle+text. Pack your controls two by two in Horizontal StackPanels Then pack those StackPanel into a vertical StackPanel, then render. You have to keep track for each page which control was rendered last, then resume rendering at the following control.
Please follow this link.This is the basic which i got after searching in web world.Using this basic detail you can do any thing with print in WPF

How to use Blend to create a basic Grid

I'm a developer who's trying to get the hang of Blend. I've always used Blend to mess with control templates and such, but I'm trying to get the hang of using it for basic UI design, since I figure it's probably a bit faster than typing the XAML up manually in Visual Studio.
Right now I'm just trying to create a basic Grid, but I'm seeing two default behaviors that I'm hoping someone can show me how to change.
1) When I hover my mouse outside of the design surface, I see the temporary yellow line to show up, where the new Grid Column / Row will be when I click. The problem is that the newly created rows are set to heights like 0.2297* How do I get Blend to attach regular heights, like 250?
2) Ignoring 1), once I have some rows and columns, when I drag a button, or combo box, etc, onto one of the cells, it drops it exactly where I release the mouse, while adding some large margins to position it there. Is it possible to tell blend to just drop the control into the cell, and leave the margins alone?
Grids are awesome but it takes a bit of play to get proficient at working with them in Blend. Here are some tips to get you started (I cover this in detail in chapter 4 of my book).
1) When you use the snap lines to create rows and columns Blend automatically makes them relative (Star) sized, which is the behavior you are seeing. To change the row/column style to fixed (Pixel) sizes, click on the Padlock icons to the left and top of the desired rows and columns. Then, either edit the values in XAML or you can click near (but not on) the padlock to select the row or column. This will open the sizing properties in the Properties panel.
2) The short answer is "No". Blend will always add Margins when you draw the element in a cell unless you take care to draw them to the borders. This is too difficult and time consuming, so I just make sure I draw it somewhere inside my target cell. Now I can right-click the element and select "Auto Size > Fill" and the element will fill up the cell: no Margins, Width and Height set to Auto, and Horizontal and Vertical Alignments set to Stretch. [FWIW, addressing this is my number one feature request for Blend.]
I hope this helps.
To answer point 1) Blend is creating proportional grids so that the columns remain the same relative widths when you grow or shrink the grid rather than absolute grids. So if you want absolute grid widths you'll have to go in and edit the values by hand.
I find that it's easier to create the basic form in Blend and then tweak the values in the text editor - either in Visual Studio or Blend itself.
As for point 2) I've just tried this and as long as I click inside the column/row on the grid when placing a button it adds it to the correct column/row of the grid as expected. Select the button and then just double click inside the grid - this should add a button of default size where you clicked, but in the grid. (It would be much easier if I could see what you were doing).

Get actual height of content in Silverlight Popup control

I need to get the actual height of the displayed content inside an opened pop up control:
Problem:
I want to show a lot of data in a grid inside a pop up. If this content became higher than the browser height, this content is cropped at the end of the window.
I there any way to get the height of this content (i know that pop up isn't in the visual tree)?
Try calling UpdateLayout() once all controls have been added to your popup.
You will then be able to get the ActualHeight of the popup.
This has a bit of a performance overhead so trying calling it as little as possible.

Resources