I am trying to put up an Undo context Menu on UltraWinGrid to undo the last change that was made to the grid
The code looks like this
private void _undoAll_Click(object sender, EventArgs e)
{
this.GridName.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.Undo);
}
But its not providing the desired result. I can not use DataTable UndoChanges feature because I am binding a custom class to this Grid
Make sure you set DisplayLayout.Override.AllowMultiCellOperation to include the flag that allows the Undo operation.
In code you should set something like this in your Form_Load event:
this.GridName.DisplayLayout.Override.AllowMultiCodeOperations =
AllowMultiCellOperation.Undo | AllowMultiCellOperation.Redo;
also I have found this thread on Infragistics site that explain better what going on here
Related
Edit:
Simple answer: Yes, it does. I found the error, which was, that another event handler was added, everytime the Combobox_SelectionChanged was fired. Hence, the collection looked fine, but the Items_CollectionChanged was fired multiple times. Once this was fixed, everything worked fine.
End Edit.
I've got a page with a combobox and a grid. The grid fills dynamically, when the selection in the combobox changes. I'm now observing a strange thing. When I select a value for the second time in the combobox, the childitems in the grid appear twice. I've checked the underlying collections, which look fine (i.e. only one record per item). When I jump out of the combobox_SelectionChanged method, after the Grid.Children.Clear() command, the screen looks fine, i.e. empty.
My guess is, that Grid.Children.Clear() only removes the controls from the visual tree, but the actual controls are still hanging around. Any Ideas?
private void combobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
grItems.Children.Clear();
grItemsColumnDefinitions.Clear();
grItemsColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(200) });
}
private void Items_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
grItems.Children.Add(new ChildItemControl(e.NewItems[0]));
}
}
Edit: The whole thing is supposed to look like this (fictional - but hopefully understandable - example)
I would suggest you use the built in Databinding for WPF. You could use something like this:
<DataGrid x:Name="grItems" ItemsSource="{Binding comboboxItems}" />
Then, when you update comboboxItems your grid will automatically update too!
Here is a great article on Databinding with the DataGrid control:
http://www.wpftutorial.net/DataGrid.html
For more information about Databinding in general, here is a good article: https://msdn.microsoft.com/en-us/library/aa480224.aspx
I can't seem to find an answer to this, maybe I'm not using the correct terminology.
I have a ListView that is editable, I want it so that if a user clicks on Edit and then Update, that the field is updated with the value from another textbox, not the field they are editing.
The reason for this is that I have a Colour Picker that alters the value of a textbox, when they click Update I want this value to be the updated value.
I guess I utilise the ItemUpdating event, but I don't have much in the way of code because I'm pretty lost. I have this so far:
protected void ListView2ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
var selectedItem = ListView2.Items[ListView2.EditIndex];
// I have no idea what to put here
something = ColourChosen.Value;
}
Here is an image that I hope will make what I'm trying to do a little more understandable:
If any one could point me in the right direction of any examples, that would be much appreciated.
Although this doesn't answer my initial question this does what I want to happen.
What I should be doing is altering the database that ListView is attached to.
I use this code:
protected void ListView2ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
using (var myEntities = new i96X_utilEntities())
{
var myPlotColour = (from plotC in myEntities.PlotColours
where plotC.ID == selectedID
select plotC).Single();
myPlotColour.PlotColour1 = ColourChosen.Value;
myEntities.SaveChanges();
}
}
So, even though I have no idea how to intercept a field being updated in a ListView, in this example I don't need to.
I have an infragistics UltraWinGrid and I want to disable the first column or make it "readonly". What is the way to do this?
I tried (none of these worked):
_ultraGridRetailers.DisplayLayout.Bands[0].Columns[0].CellActivation = Activation.Disabled;
_ultraGridRetailers.Rows[0].Cells[0].Activation = Activation.Disabled;
For any specific question it will be better to contact the support of Infragistics, but there is regarding your question: Blog one
Try to debug your aplication and see if you are setting this behavior too early or if you are reseting it in code after the pointed one. According to the blog post this should be the way to acieve the goal, and if it is not working you better contact the support and submit a development issue.
What I have tried is hooking to the InitializeLayout event of the UltraGrid like the following, and setting there the desired properties of the columns, which does work for me correctly:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
//Make the column disabled or
e.Layout.Bands[0].Columns[0].CellActivation = Activation.Disabled;
//Make the column readonly
e.Layout.Bands[0].Columns[0].CellActivation = Activation.ActivateOnly;
}
If the above doesn't work for you, most probably something overrides those settings in a later stage of your application.
if I add control in Microsoft Blend 4 without set Name to this control and I want to set name to it and use it in c# how ?
example I added button using Blend in my layout but without give it a name
I want to give it a name using c# without x:Name="" in xaml
In your place I would give LogicalTreeHelper.GetChildren (this) a chance. It returns a collection of children to Window (this is a handle to Window) Reference MSDN
From there you can try to find your control.
But I think it is easier to try to rewrite the control (or look for another component) so you can have names on the children. That was your problem from the start.
Hope it helps
Gorgen
First, why in the world would you want to do that?
If you do not set a name you have no easy way of accessing the control. However you can get access to the control via relationships to other controls or events that pass a reference, for example the loaded event.
e.g.
private void Menu_Loaded(object sender, RoutedEventArgs e)
{
(sender as Menu).Name = "MainMenu";
}
Or if the control is the child of another control:
(ControlStack.Children[0] as Menu).Name = "MainMenu";
But i cannot think of anything useful that could be achieved by that...
You probably just want to get a reference to the object which you can easily store in a class member. In some cases you can also slice up your XAML using resources.
e.g.
<local:SomethingIWouldLikeToReference x:Key="SomethingIWouldLikeToReference"/>
<local:UserControl x:Name="userControl">
<Stuff>
<MoreStuff Content="{StaticResource SomethingIWouldLikeToReference}"/>
</Stuff>
</local:UserControl>
public MainWindow()
{
InitializeComponent();
MyReference = FindResource("SomethingIWouldLikeToReference") as SomethingIWouldLikeToReference;
}
Example if I have ListView Control and I want to use it to add items and remove items
Make private ListView and initialize it
ListView temp_control_List = new ListView()
then make loaded Eventhandler from Blend so it will be in VS then
private void ListView_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
temp_control_List = sender as ListView;
}
Now you can add and remove to and from the list view control from temp_control_List
I'm developing a tool which shows data from a database in a hierarchical manner. As there are additional data for each item I'm using a TreeListView control to display them in additional columns. The number of columns is determined by user input.
The custom control that I'm using is Ricciolos TreeListView:
http://windowsclient.net/blogs/ricciolocristian/archive/2008/03/22/a-complete-wpf-treelistview-control.aspx
My problem now is, that I need to catch the ColumnHeaderClick event to apply a sorting logic. I already interviewed auntie Google, but no results.
Maybe somene here knows where to find such an event and how to determine which column header has been clicked.
Thanks
You would need to add a handler for the GridViewColumnHeader.Click event. This post describes how to do it for the ListView, which uses the same underlying controls. This code was adapted from that link:
myTreeListView.AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(this.OnGridViewColumnHeaderClicked));
private void OnGridViewColumnHeaderClicked(object sender, RoutedEventArgs e) {
MessageBox.Show("testing");
}
Alternatively, you can attach a handler via XAML like so:
<my:TreeListView GridViewColumnHeader.Click="OnGridViewColumnHeaderClicked" />
The e.OriginalSource will include the GridViewColumnHeader, and e.Source/sender would be the TreeListView.