Is there a way to define a specific CellChange event handler for each column of a UltraWinGrid?
I'm refactoring a CellChange event handler for an Infragistics UltraWinGrid that looks like this:
Select Case e.Cell.Column.Key
Case "Name"
' handle cell change event for Name cell with a big ugly blob of code
Case "Title"
' handle cell change event for Title cell with a big ugly blob of code
' ... etc ...
End Select
I'd like to be able to create event handlers that fire when a cell of a specific column is changed, but I don't know if that is possible. If it's not, I'll just refactor the select-case to manually call the column-specific event handlers.
Select Case e.Cell.Column.Key
Case "Name"
CellChanged_Name(sender, e)
Case "Title"
CellChanged_Title(sender, e)
' ... etc ...
End Select
Can someone tell me if it's possible to create event handlers that fire when the cell of a specific column is changed? Or am I better off just manually calling the column specific functions?
Please, note, I'm translating this from C# on the fly, so something could be wrong.
You need to reference the Linq namespace and then use syntax like this
in your form_load or somewhere else
Dim dictionary As New Dictionary(Of String, Infragistics.Win.UltraWinGrid.CellEventHandler)
dictionary.Add("Name", CellChanged_Name)
dictionary.Add("Title", CellChanged_Title)
dictionary.Add("....", ....)
in your common CellChanged event
dictionary(e.Cell.Column.Key).Invoke(sender, e)
as a reference please look at this Replacement for big switch?
The event handlers for the CellChange event handler will always be called when there is a change to any cell and the grid doesn't have a way to create an event handler for a specific column. If you want you could reach out to Infragistics and recommend that they add this feature through the forums or by submitting a support request. There are links for this each on the get help page:
http://www.infragistics.com/support/get-help.aspx
Related
In Infragistics Ultra Grid I have to disable a Boolean (Check box) cell based on a condition in Initialize Row event
PS: I don't want entire column to be disabled. Just only cell should be disabled (cell which contains check box should also be disabled).
I kept code like below
e.Row.Activation = Activation.NoEdit
This code is disabling all the cells in ultra grid row. But a Boolean checkbox which is present in a cell is not getting disabled.
try something like:
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{ // deactivate boolean in cell 0
//ultraGrid1.DisplayLayout.Bands[0].Columns[0].CellActivation =
// Infragistics.Win.UltraWinGrid.Activation.Disabled;
e.Row.Cells[0].Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled;
}
Other choices available beside Disabled are: ActivateOnly, AllowEdit, and NoEdit
You can always come back and activate it.
Here is another idea. Instead of a boolean cell, make it a System.Drawing.Bitmap and create your check boxes, checked, and unchecked.
and then create/modify an image(s) for disabled.
On the cell click event, change the cell image according to your needs. If need be, create an additional hidden column to store the state/value of the cell. This is something I did when I created/translated a Java version of my c# application to run on other platforms and it worked out great. (Feel free to use these images if it helps)
Found the root cause. In base class there is one mouse down event due to which checkbox in ultragrid is being enabled. Even though if i kept logic like this e.Row.Activation = Activation.NoEdit.
Thank you all for your help.
I am using a QTableWidget and I have a requirement that the user is able to highlight specific text in a cell, but the cell contents should not change if the user accidentally erases or modifies some cell contents. I was thinking that the simplest way to accomplish this would be to just ignore any edits that occur when the user finishes editing a cell. Any ideas how to do this?
Using C++ 98 and QT
You can access the table widget items and modify their properties You want to disable the Qt::ItemIsEditable flag :
QTableWidgetItem* item;
item->setFlags(item->flags() & ~(Qt::ItemIsEditable));
A good way is to set the item prototype before inserting cells into the table. Right after creating the table
const QtableItem* protoitem = table->itemPrototype();
QtableItem* newprotoitem = protoitem->clone();
newprotoitem->>setFlags(item->flags() & ~(Qt::ItemIsEditable));
table->setItemPrototype(newprotoitem);
Now every new cell in the table will have the editable flag disabled. If the user double click it will not open the text edit in the cell.
ps: Do not delete newprotoitem afterwards.
This is late, but for follow-on searches:
The best way to do this is to subclass a delegate (QStyledItemDelegate is the least problematic - no abstract virtuals).
In the delegate, override 'setModelData()' to a stub. The editor will still come up, and you can still change its contents, but the edit won't 'take'. As soon as you leave the cell, it will revert to its original contents.
If you want to prevent the editor from accepting keys (QLineEdit), override 'createEditor()' in your delegate. Call the base class to create an editor, check its type, and then install an event filter on the editor to reject keypress/keyrelease events.
Return the editor in your override.
Works for me, although I did have to const_cast 'this' (to non-const) to install the event filter.
The situation is as follows :
I am creating a row in the grid. I have several properties among which are one combo called 'department' and one field called 'name'. The business rule is that all the 'names' in a 'department' must be unique. The grid does not load all the department-name combinations so I have to make a call to the back-end. I want to make this call when
selectionChanged on the 'department' combo happens or
when 'checkValue' of the validator options of the 'name' filed happens.
This way I check when either changes. The problem is that this happens during creation and there are no rows in the datasource and no accumulated rows in the transaction log.
How can I access the fields of the 'rowEditTemplate' during creation during these particular events in order to check my values? Is there any other/better way to achieve this?
The editors are not created until you do the first edit. You could use the editRowStarted event to attach your editors logic. They are obtainable using the editorForKey method.
editRowStarted: function (evt, ui) {
var comboEditor = ui.owner.editorForKey("ProductDescription");
}
I created a small fiddle that assigns a data source for the combo on editRowStarted. It should work as a starting point for what you are trying to achieve.
http://jsfiddle.net/hfen0qea/
This might seem a very easy problem but I am stuck and can't find a way out of it. I am using ultragrid in my form with several columns. My issue is when I am trying to click on the column header I am expecting my entire column to be selected but it doesn't. I assumed the SelectTypeCol is the property for my column selection but it did not work either. I also tried to add each column to Selected.Columns collection like this UltraGrid1.DisplayLayout.Bands(0).Columns(i).Header.Selected = True but it didn't work for me either. I believe Selected is only available during runtime but not at the design mode.
So if there is an easier way to make this work, please let me know.
Thank you
You are looking for the property HeaderClickAction
grid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Select
This will automatically flip the selection state of the entire column as Selected (or Delected) when you click on the header. Of course this means also that you loose the ability to automatically sort on all columns
You can programmatically set the Selection state of a column with code like this (C#)
grid.DisplayLayout.Bands[0].Columns["youColumnKey"].Header.Selected = true;
this will permit to leave the HeaderClickAction property to SortSingle or SortMulti, but you have to handle the situation using code and appropriate events
You need to have an InitializeLayout event on your grid. in this event you need to set the chekboxsynchronization to default and it should work here is sample code
private void ultraGrid1_InitializeLayout(object sender,
Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
e.Layout.Bands[0].Columns.Add("CheckBox");
e.Layout.Bands[0].Columns["CheckBox"].Style = ColumnStyle.CheckBox;
e.Layout.Bands[0].Columns["CheckBox"].Header.CheckBoxVisibility = HeaderCheckBoxVisibility.WhenUsingCheckEditor;
e.Layout.Bands[0].Columns["CheckBox"].Header.CheckBoxSynchronization = HeaderCheckBoxSynchronization.Default; <-- make sure it is set to default here
}
I have a question. I have a GtkListStore and a GtkTreeView, and I want to sort the GtkListStore and update the result to the GtkTreeView when the user clicks on a certain column of the GtkTreeView. I am assuming that the columns are clickable, and cannot be re-ordered, so the numerical order of the columns can be used to set the sorting column's index. But I cannot seem to find which signal gets emitted when the user clicks on the header of a particular column. I have gone through the GTKMM documentation time and again, but it does not seem to be mentioned!
Use Gtk::TreeView::get_column(<column-no>) to get a particular column and attach to its "clicked" signal using Gtk::TreeViewColumn::signal_clicked():
Gtk::TreeViewColumn* col = myview.get_column(SOME_COLUMN_NUMBER);
col->signal_clicked().connect(sigc::mem_fun(*this,&some_method));
That's not how you're supposed to do it.
There can be several views hooked up to the same model; sorting is not something you do to the model, it's something you do to the view.
See the GtkTreeSortable interface (and its GtkTreeModelSort implementation).