Infragistics UltraWinGrid disable first column - c#

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.

Related

Caliburn Micro disable buttons which have no Property?

At the moment i'm working with Caliburn Micro. But i got to a problem which i don't know how to solve.
The problem is i want to disable Buttons, but every website has only a solution with propertys. the functions of my buttons for example just start a thread to establish a connection over tcp with Netmq. So i don't know how i'll be able to disable them. Searched a lot through google but didn't find anything helpful.
Example of a button function
public void startPubButton()
{
Thread entryThread = new Thread(startPublisher);
entryThread.IsBackground = true;
entryThread.Start();
}
is there maybe a possibility to enable the Buttons only when the thread runs ?
That is the one premise behind CM wiring up by convention all you have to do is provide a CanstartPubButton Boolean property run a code check to see if you can enable or disable button according to the logic with that guard property. Call with NotifyOfPropertyChange(() => CanstartPubButton); in some fashion to do what you want. The logic with in the property (get only needed) is up to you. one other thing I will drop on you is a thread presently in the GitHub discussions on the repository itself. Might help and it might not
https://github.com/Caliburn-Micro/Caliburn.Micro/issues/422

Undo Context Menu on UltraWinGrid

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

Binding height, width, etc to a variable

I don't know if I'm just not understanding what I've found so far, or if it really is too complex to apply to such a simple idea as it seems. I'm trying to bind a button's height and width to variables that are stored in user settings. I can't seem to get this to work, or rather I simply don't how to, as in what commands to use. The issue lies in not knowing what to put in the Binding field of the xaml. If anyone could point to a guide that involves just this, could explain what to do I would be very appreciative.
Edit: I've solved the problem of binding the variable, it now saves to the User setting file when it should. Now I'm having an issue with the value stored in user setting beig overwritten every time the program loads with the default value. I am running this through VS debug menu selection, so I suppose the issue could lie there, but I've tried publishing it and running and still getting the same results. Any ideas?
Assuming by 'User Settings' you mean the built-in Settings not a custom implementation:
See http://blogs.windowsclient.net/bragi/archive/2008/07/03/using-settings-in-wpf-or-how-to-store-retrieve-window-pos-and-loc.aspx for an example of this - essentially you want to set up TwoWay bindings to Properties.Settings.Default: note that you have to define the settings in advance using the Settings UI, and you have to call Properties.Settings.Default.Save() when the app exits to persist the settings.
I'm posting this answer so that hopefully somebody else can read it and avoid such a ridiculous problem. First off, as far as the initial question, Staurt answered it quite nicely. But my edit above brought up a new but related problem. I ended up fixing it on accident.
The whole purpose of this was that I have a slider bar that adjusts the size of a shortcut button dock. The slider worked, but as I said above it would reset itself every time I reloaded. The issue in this case was that I have the buttons set to resize as the slider moves, so I used the slider_ValueChanged event as you can see here:
private void iconSizeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
try
{
Properties.Settings.Default.iconHeight = Convert.ToInt32(iconSizeSlider.Value);
Properties.Settings.Default.iconWidth = Convert.ToInt32(iconSizeSlider.Value * 1.3);
Properties.Settings.Default.Save();
//iconWidth.Text = buttonWidth.ToString();
//ButtonRefresh();
}
catch (FormatException)
{
}
}
While trying to use the Run To Cursor part of VS2010, I got tired of having to F11 through a multitude of loading steps, so as a debugging tool I added a bool fullyInitialized flag. This solved the problem completely. Apparently (which I didn't realize before), when the slider was first initialized it considered the value to have changed, so when it ran through the ValueChanged method, it reset everything to default. So adding a simple conditional around the try-catch to check for the fullyInitialized flag solved everything. Hopefully this helps somebody else.

How to hide textboxes, labels and buttons C# WPF

I would like to hide several textboxes, a label and a button as soon as a button is clicked... however, for some reason, my code doesn't seem to cause this effect. Nothing appears to happen. I'm using WPF.
Here is my code:
private void doSomething_Click(object sender, RoutedEventArgs e)
{
Name.Visibility = Visibility.Hidden;
}
This code doesn't seem to work.. any ideas?
I believe Visibility.Collapsed is what you need and not Visibility.Hidden.
EDIT: Did you try follow up this code with UpdateLayout() method of parent element/component?
Your code seems to work fine, the "Signing in..." label appears after everything else disappear. I suggest you to just copy all your code from the .xaml.cs file and the .xaml file into a new project, but make sure you don't copy the first line"<Window x:Class="..." because it could generate an error if the class name isn't the same in the new project.
For the xaml code I suggest you not think the same as you design windows forms applications. WPF has the layout system, which re-orientates or re-sizes its elements when re-sizing the window. So you should not specify exact numbers in the margin property as if they where coordinates. Create a grid, create rows or columns for each element and then just set the horizontal or vertical alignment or margins. Think different than the old windows forms way.
I've run your code... and it's working great for me. I've not changed anything (except the variable names) so I guess it's a bug from VS.
As said nikolamm94 try to add this.UpdateLayout(); at the end of connect_Click it might help. I tried and it is still working fine. Or maybe create a new VS projet, it already worked for me a few times.
Sorry my answer is not the most helpful, I wanted to put a comment instead but I don't have enough reputation :/
Please refer: https://msdn.microsoft.com/en-us/library/ms748821(v=vs.85).aspx
Set to Visible: tb1.Visibility = System.Windows.Visibility.Visible;
Set to Hide: tb1.Visibility = System.Windows.Visibility.Hidden;
You can hide a textbox by going to properties->appearance->visibility, then setting it to "hidden"

DevExpress DXGrid column header double click event

I have to check / uncheck all the checkboxes (toggle) in a column when the user double clicks the column header.
How can I implement this behaviour in the DevExpress DxGrid control?
I have searched the DevExpress support forum but I haven't found a solution.
Also, i am working on MVVM Pattern.
This case works for WinForms, not tested in WPF yet, I posted might it direct you to some lights:
There is a workaround to accomplish this behave, you have to implement yourGrid_DoubleClick Event Handler, then calculate the hit Info of the mouse click, the hit info object will tell you if the double click was on a column, something like:
private void yourGridViewName_DoubleClick(object sender, EventArgs e)
{
DevExpress.XtraGrid.Views.Grid.GridView sndr =
sender as DevExpress.XtraGrid.Views.Grid.GridView;
DevExpress.Utils.DXMouseEventArgs dxMouseEventArgs =
e as DevExpress.Utils.DXMouseEventArgs;
DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hitInfo =
sndr.CalcHitInfo(dxMouseEventArgs.Location);
if (hitInfo.InColumn)
{
string x = hitInfo.Column.Name;
//Rest of your logic goes here after getting the column name,
//You might now loop over your grid's data and do your logic
}
}
but you have to notice that this action will not prevent the sorting that column's header do, you might need to disable sorting for this grid
Hope this helped.

Categories