How do I make "TreeListControl" appear as a "TreeView"? - c#

VS 2017
DEVEXPRES 17.2
WPF
There is a table in MS Access
Based on the table, "TreeListControl"
How to make "TreeListControl" appear as "TreeView"
I want to say how to make sure that items that are marked with crosses are not displayed
In WinForm, this is done when you set it in the menu "ViewStyle" / "TreeView"
In WPF, I did not find this.
Question.
How do I make "TreeListControl" appear as a "TreeView"?

You can accomplish your task by hiding some TreeListControl's TreeListView visual elements:
column headers (the TreeListView.ShowColumnHeaders property)
lines between cells (the TreeListView.ShowHorizontalLines and the TreeListView.ShowVerticalLines properties)
indicator panel (the TreeListView.ShowIndicator property)
And of course, you should have the only single column visible at once (the TreeListColumn.Visible property);

Related

Cell navigation to GridControl

I use DevExpress
I had difficulty managing. I have a GridControl and added cell navigation buttons. That's just the question, how can you implement this code?
There are 4 buttons, among which are: First entry (|<), Previous entry (<), Next entry (>), Last entry (>|). How can you programmatically write these cell movements?
An example of an Access screen, such as this navigation:
My suggestion would be to not write it yourself... use the Dev Express embedded navigator.
If you go to designer view on the grid, go to Feature Browser, Focus, Embedded Navigator and set the UseEmbeddedNavigator property to true.
You can, of course, also do this in the regular property window of your form.
Once you do that, your grid will have it:

In a property grid is there a way to unselect all grid elements programatically?

I am working on a project in which I am using a property grid to display the properties of the selected control.
The Property Grid is fixed to the left edge of the container and in the rest of the space I have the form I am designing.
On clicking a control on the form, the specific control’s property is getting selected.
In the above figure, I have selected the textbox and the textbox’s properties get shown on the propertygrid.
Here if you observe, by default, the Name property is highlighted as well.
Is there some way to unselect this property programmatically?
I have tried some suggestions online but none have helped. I am not able to find find a way to remove all selections from the PropertyGrid, but its behaviour seem to be different form a DataGrid...
Here is why I need this...
On selecting a control, if a property in the property grid is selected, then the property is getting modified.
For example, If i cut the control using Ctrl + X, the selected value in property grid is getting cut which in some cases is forcing user to set the property before modifying anything on the form.
I have tried selecting multiple controls, but in that case alse the selected property seems to be persistent
Since PropertyGrid uses DefaultProperty to select a property in its grid, as an option you can set DefaultProperty attribute at run-time for your object to a non-browsable property, for example:
this.propertyGrid1.SelectedObject = null;
TypeDescriptor.AddAttributes(someControl,
new Attribute[] { new DefaultPropertyAttribute("Site") });
this.propertyGrid1.SelectedObject = someControl;
Well, what you are trying are hacks. It is never a good idea to do such hacks particularly if you are not the only person that use the software.
In your case, the focus should be on the designer while you interact with it. So if the user press Ctrl+X, the designer should respond to the keyboard and it should not have any effect on the property grid (as only one control can have the focus at the same time).
Thus it is up to you to make sure that your designer is focusable, that it has the focus when initially displayed, that it get the focus when you press the TAB key. Pressing the TAB key again should put the focus on the property grid so that user can interact with the grid without using the keyboard.
If you have more than these 2 controls, then obviously TAB should also stop at any appropriate controls. Also, it can be a good idea to have some direct shortcuts like F4 to (show and) activate the properties pane.
If you are not able to make it works, then the best compromise would be to use another windows for the properties grid. By using a distinct Tool windows for the properties, it should not respond to the keyboard when the main windows has the focus.
Here are some links that might help you:
Panel not getting focus
Control.Focus Method() — See Remarks section.
In any case, you should not prevent Ctrl+X to works as expected when the property grid has the focus and a property is selected. Users don't like software that do not follows UI conventions.
As a software developer, you should as much as possible ensure that your application follows standard behaviors. I recommend you that you take one or 2 extra days developing your software properly instead of doing hacks.
Often, compromise to gain a few days will never be fix and will be a pain for many years. Better to do it right from the start. Unselecting an item in the property grid is not an acceptable workaround. Your manager should not allows you to do that.

How can I create a table like Visual Studio's watch window?

I want to display data about some objects in my program, in a way similar to how Visual Studio's watch window works - A tree list with two columns, name and value, with the ability to expand non-primitive members further as child nodes in the tree structure.
I've been trying to do this with ObjectListView, but I can't seem to get it to happen. OLV seems to want to stick the members in individual columns, horizontally, while I want them to be displayed vertically, under the parent object (if that makes sense).
For winforms project there is a control - PropertyGrid that does this almost automatically, you need to set some attributes on the properties:
[ReadOnly(bool)] – is the property read only.
[Browsable(bool)] – is it browsable, i.e to show in the property grid or not.
[Category(string)] – the parent group of the property
[Description(string)] – the description. It is displayed on the bottom label when you select the property.
[DisplayName(string)] - you can override the display name.
Additional information you can find here: https://msdn.microsoft.com/en-us/library/aa302326.aspx

Strange VS2010 behavior with datagrid and designer

I am working on a winforms app with a DataGridView control on it, and I am experiencing some frustrating things.
First off, I want to turn off AutoColumnGeneration, but it's not listed in the properties. No problem, I can do that with a line of code...and this is where it gets weird:
In my code, the DataGridView is inaccessible. Its like it doesnt exist on the form. Looking into this, its because the designer is declaring it as part of the InitializeComponent() method instead of where it initializes all the other controls.
Because its in the designer, any change I make there gets reversed so I can't fix this.
Is there any way to stop visual studio from doing this? I found a hack around it by using one of the datagrid columns (which ARE accessible) to create a reference to the datagridview its associated with and access it that way. It works, but its ugly and not intuitive at all.
I think I found it:
In the designer, click on the DataGridView control, and change the property of GenerateMember to true. I'm guessing it is set to false.
That property is used to do just that: hide the control from the code windows. It's useful for Labels or ToolStripSeparators that you don't need to deal with in code.
I personally use the binding source as the datasource which can even be an object and then under columns it will list all of the available columns and you can pick and choose which ones are visible as well as a slew of other options including formatting.
Click the drop down on the datasource and Add a new data source and select the necessary object, in my case an order detail object. Here is some of my designer code which is created by VS2010
this.dgvOrderDetails.DataSource = this.orderDetailBindingSource;
this.orderDetailBindingSource.DataSource = typeof(OrderDetail);
And the binding source code that sets up the data to fill the datagridview (I coded this part)
orderDetailBindingSource.DataSource = orderDetList;
Then just click the ellipses on the Columns property of the datagridview and it will have all the columns listed that are available from the object and I set the ones I want visible, the order, format etc.
As for the 2nd issue I don't think you'll have that problem once you use the designer to make the changes I listed above.
In my case, I declared a private property in the Form's partial class (the file for my code, not the Designer's file) to return the control by navigating through the Controls hierarchy.
private DataGridView MyGrid
{
get { return (DataGridView)this.Controls[0].Controls[1].Controls[0].Controls[1].Controls[0]; }
}
I agree, there ought to be a better way, such as Visual Studio Designer declaring the control like it does most other controls on the form. In the meantime, this works.
Warning!
If the form's control hierarchy is ever changed, the property's definition will have to be manually updated.
Edit
I have a better solution - at least in Visual Studio 2012.
While in the form Designer, with the DataGridView selected, open its properties and look for the GenerateMember property (under the Design node) and ensure it is set to True. Once set to True, the Designer will declare a member variable for the DataGridView control.
The strange thing is that the default value appears to be True, so I'm curious how it was changed to False? Perhaps I mis-clicked when setting the name?
By the way #LarsTech's answer is the same as this update.

WPF How to make "layer"

I am developing a small appplication which is single windowed...
I have formated everything with care .. The window contains a grid which has 2 columns.. The second is auto and the first is of type *.(takes the remaining space)
Is there a way to change the content of the first column ?(to display a chart for example)
The only solution i can think is a tabcontrol with invisible tabs to switch programmatically, or create a custom user control and place it somehow..but the last solution i think sucks because the content i want to display isnt just a user control..
In java i could do this very easilly,is there any solution here?(i dont want to mess the design view!)
You could
put a <ContentControl> in XAML where you want to exchange contents.
give it a name (x:Name)
Now you can target the control. It supports IAddChild such that you can attach any child object to be displayed.

Categories

Resources