I have a grid with multiple columns. In one of the columns I need to show 3 buttons and in another column I need to show 2 buttons.
When the screen loads I create a three button editor and a two button editor. See code below:
private UltraTextEditor TwoButtonEditor = new UltraTextEditor();
private UltraTextEditor ThreeButtonEditor = new UltraTextEditor();
private void CreateTwoButtonCellEditor()
{
EditorButton Charge = new EditorButton();
EditorButton Waive = new EditorButton();
Charge.Text = "C";
Charge.Width = 34;
Charge.Key = WorkViewAccountsConstants.CHARGE_KEY;
Waive.Text = "W";
Waive.Width = 34;
Waive.Key = WorkViewAccountsConstants.WAIVE_KEY;
TwoButtonEditor.ButtonsRight.Add(Charge);
TwoButtonEditor.ButtonsRight.Add(Waive);
TwoButtonEditor.EditorButtonClick += TwoButtonEditor_EditorButtonClick;
}
private void CreateThreeButtonCellEditor()
EditorButton Approve = new EditorButton();
EditorButton Reject = new EditorButton();
EditorButton HFF = new EditorButton();
Approve.Text = "A";
Approve.Width = 34;
Approve.Key = WorkViewAccountsConstants.APPROVE_KEY;
Reject.Text = "R";
Reject.Width = 34;
Reject.Key = WorkViewAccountsConstants.REJECT_KEY;
HFF.Text = "H";
HFF.Width = 34;
HFF.Key = WorkViewAccountsConstants.HFF_KEY;
ThreeButtonEditor.ButtonsRight.Add(Approve);
ThreeButtonEditor.ButtonsRight.Add(Reject);
ThreeButtonEditor.ButtonsRight.Add(HFF);
ThreeButtonEditor.EditorButtonClick += ThreeButtonEditor_EditorButtonClick;
In the InitializeRow event of the grid I add the editors to the correct row cells like this:
row.Cells[WorkViewAccountsConstants.COL_DECISION_BUTTONS].EditorComponent = ThreeButtonEditor;
row.Cells[WorkViewAccountsConstants.COL_FEEDECISION_BUTTONS].EditorComponent = TwoButtonEditor;
When I show the grid, the buttons in the cells do not appear. When the mouse enters the cells, the buttons appears. When the mouse leaves the cells the buttons disappear. I read a post where a ToolTip was causing this issue so I added the following statement to the grid to turn off the ToolTip:
this.gridTransactions.DisplayLayout.Override.TipStyleCell = TipStyle.Hide;
The problem still exists.
Is there something I'm not doing correctly? Also, how do I capture when the user clicks a button in a cell? I added the event handler you see in the code above, but when I set a break point in the ThreeButtonEditor_EditorButtonClick and TwoButtonEditor_EditorButtonClick methods, nothing happens. The event isn't firing.
Hi,
There's nothing wrong there, the buttons are only supposed to show up when the mouse is in the cell or when the cell is Active. That's the intended behavior.
If you want the buttons to show all the time, you can set the ButtonDisplayStyle property on the column to Always.
Regarding the events, I don't see anything wrong with the code you have here. You are hooking the EditorButtonClick event of the editor, and that's the correct way to handle it. I don't see any reason why the events should not be firing.
I create an UltraTextEditor with buttons in the ButtonsRight collection like this:
private UltraTextEditor CreateNewThreeButtonCellEditor() { UltraTextEditor ThreeButtonEditor = new UltraTextEditor(); ThreeButtonEditor.AlwaysInEditMode = true;
StateEditorButton Approve = new StateEditorButton(); StateEditorButton Reject = new StateEditorButton(); StateEditorButton HFF = new StateEditorButton();
Approve.Text = "A"; Approve.Width = 34; Approve.Key = WorkViewAccountsConstants.APPROVE_KEY; Approve.DisplayStyle = StateButtonDisplayStyle.StateButton; Reject.Text = "R"; Reject.Width = 34; Reject.Key = WorkViewAccountsConstants.REJECT_KEY; Reject.DisplayStyle = StateButtonDisplayStyle.StateButton;
HFF.Text = "H"; HFF.Width = 34; HFF.Key = WorkViewAccountsConstants.HFF_KEY; HFF.DisplayStyle = StateButtonDisplayStyle.StateButton;
ThreeButtonEditor.ButtonsRight.Add(Approve); ThreeButtonEditor.ButtonsRight.Add(Reject); ThreeButtonEditor.ButtonsRight.Add(HFF);
ThreeButtonEditor.BeforeEditorButtonCheckStateChanged += ThreeButtonEditor_BeforeEditorButtonCheckStateChanged; ThreeButtonEditor.AfterEditorButtonCheckStateChanged += new EditorButtonEventHandler(ThreeButtonEditor_AfterEditorButtonCheckStateChanged);
return ThreeButtonEditor; }
Now, in InitializeRow of the grid I assign the UltraTextEditor to a column of the grid. Each row gets its own UltraTextEditor.
UltraGridRow row = e.Row; row.Cells[WorkViewAccountsConstants.COL_DECISION_BUTTONS].EditorComponent = CreateNewThreeButtonCellEditor();
This displays all good. I can trap the events. However, I have a couple of problems.
The main question is How do I get to the StateEditorButtons to enable/disable them and check/uncheck them?? I was trying code like this:
row.Cells[WorkViewAccountsConstants.COL_DECISION_BUTTONS].EditorComponent = CreateNewThreeButtonCellEditor(); row.Cells[WorkViewAccountsConstants.COL_FEEDECISION_BUTTONS].EditorComponent = CreateNewTwoButtonCellEditor();
UltraTextEditor threebuttonEditor = row.Cells[WorkViewAccountsConstants.COL_DECISION_BUTTONS].EditorComponent as UltraTextEditor; EditorButtonsCollection decisionBtnColl = threebuttonEditor.ButtonsRight;
UltraTextEditor twobuttonEditor = row.Cells[WorkViewAccountsConstants.COL_FEEDECISION_BUTTONS].EditorComponent as UltraTextEditor; EditorButtonsCollection feeDecisionBtnColl = twobuttonEditor.ButtonsRight;
...
StateEditorButton a = decisionBtnColl[WorkViewAccountsConstants.APPROVE_KEY] as StateEditorButton; StateEditorButton h = decisionBtnColl[WorkViewAccountsConstants.HFF_KEY] as StateEditorButton; StateEditorButton r = decisionBtnColl[WorkViewAccountsConstants.REJECT_KEY] as StateEditorButton;
/*** Then I try to do stuff to the editor buttons***/
a.Checked = true;( This seems to work but when the grid shows the editor button is not checked. See point #2 below. )
a.Enabled = false; ( This seems to work but when the grid shows the editor button is not disabled. See point #1 below. )
#1 How do I enable/disable individual StateEditorButtons??? Based on various rules users may not be able to click all the buttons so in InitializeRow I'm trying to enable/disable buttons.
#2 In InitializeRow I check/unchecked StateEditorButtons based on data. When the screen loads the buttons are not checked. However, if I manually click the button it shows checked.
#3In an .isl StyleSheet file, we created a style of the StateEditorButton's Check and UnCheck state. However, this style isn't being applied to the StateEditorButtons. It appears to be using a default. Styles are being correctly applied to other Infragistics objects so I'm not sure what's going on here. I set the Check style to GREEN and Unchecked to BLUE, so it should be obviously if it applies.Here it is: <style role="StateEditorButton"> <states> <state name="Checked" backColor="77, 232, 0" backGradientStyle="None" backHatchStyle="None" /> <state name="Unchecked" backColor="22, 100, 255" backGradientStyle="None" backHatchStyle="None" /> </states> </style>
I hope someone can help (with code samples). My design depends on getting these edition button to work. Please let me know what I am doing wrong here.