I am more of a web developer, but I was recently asked to look at a WinForms application.
What I have is a Telerik WinForms RadGridView. When I click on a row, and the SelectionChange event is fired.
Within this event, pop-up a quick MessageBox to display a Yes/No confirmation if the data in the row has changed.
This is working using the following code:
So when the line
e.Cancel = true;
is executed, it acts as
$("a").click(function(event){
event.preventDefault();
});
in javascript.
The unfortunate issue that I have, is when the screen renders, the newly selected row is still highlighted and I do know how to stop this.
I have looked at the RadGridView object model and found IsActive and IsSelected attributes, but nothing appears to stop this from happening.
Looking at the image, The row with the blue bar was selected, then on selecting the cell above, showing the cell in blue and the row with a blue border. I clicked on the cancel option which passed a DialogResult.Cancel back from the warning message.
This executed the line
e.Cancel = true;
What do I need to do, to lose the blue border and blue cell colour from the selected row?
Related
My WinForm project in c#, I have DataGridview that i want to disable cell selection with mouse clicking in editing.
To be more specific; when the user keypress"=" en event fired and disable to select cell by clicking.I want to do something different instead of cell selection. Only by keypressing"ESC" or "Enter" allow to leave cell editing.
I added picture for understanding.Please help.
Within a griview (using IE), cells in one column are clickable (through gridview row command event) and once a cell is clicked it displays a hidden textbox (visible = false before the cell is clicked); users can enter text into the textbox and to allow saving changes made to the textbox users are told to press Tab key.
The saving is done through using Javascript by checking keycode in keydown event, it simply checks when keycode = 9 (Tab key) __doPostback('OnClick','SaveButton'); in codebehind SaveButton onclick event simply calls a store procedure to save the new text changes into database.
The problem I have is keydown event is not ALWAYS fired though it works most of the time. There seems to be no difference to the situation when it works and when it doesn't, so to me it's a bit random and I have to emphaise that it works 90% of the time.
Worth mentioning that when users click the cell to edit the textbox, gridview row updating event is fired first since I need to enable gridview row updating event not only for this column text changes but also for other columns data updating.
When everything 'works' after user pressing the Tab key, the event sequence is:
Gridview row updating
Keydown/SaveButton click
Gridview row updating
I don't understand what triggers the event 3 i.e. the second gridview row updating event though it doesn't do any harm to anything as it's after the text being saved into database. But when pressing Tab key doesn't work (text not saved) the second gridview row updating event is not fired; only the 1st row updating event is fired and textbox changes are lost reverting back to the original text.
I'm new to asp.net and hope someone can shred some light on this problem.
I found out why GridView row updating event fired for the 2nd time, it's because AutoPost for the editable textbox being set to True.
silly me...
I have created a DataGridView in a forms based application.
I have preselected some some rows based on some conditions using the following code:
DataGridView1.Rows[i].Selected = true;
now I have a button which allows the user to move the focus(record pointer) to the next selected row.
When the user clicks the button I do the following
DataGridView1.CurrentCell = DataGridView1[0,row_number];
but when this happens the previously selected row loses the highlight.
I want to maintain the highlight (selection) of the previous row also but the record pointer should be moved to the next selected row.
How can I acheive this.
When you make DataGridView1.CurrentCell equal to a single cell (row), the multiselection is converted into single selection and thus all the other rows are deselected (Selected property set to False).
There are various options to avoid that:
The most logical option is not relying on DataGridView1.CurrentCell
at all. You can create your own variable to store the current cell
being edited (you might even store it in the DataGridView itself, via
its Tag property).
Another option would be affecting the style (background color) of the rows selected sofar to transmit to the user the impression that they are
still selected. Although this second option is not too recommendable,
as far as all the "associated features" (e.g., Selected property)
would continue behaving as if these rows wouldn't be selected.
I have a winforms application that has a datagridview control. Now, when I click on a cell in the datagridview control, the view shifts/pans the datagridview control, such that the cell selected is more or less in the centre of the screen. Is there any way to disable this? My users find this irritating.
The data gridview is essentially needed only to show colour codes (i.e. no text) and tooltips for each cell. I have tried
datagridView1.Enabled = false;
This solves my problem, however, I can no longer view the tooltip text.
Is there any other work-around? Is it possible to prevent the user from clicking on a cell in the first place to prevent this?
I have a data grid displaying results from a sql database. What I want to do is make it so that when I double click on a cell in the datagrid, a new window appears where that cell can be edited. I also would like to have all the info for that cell to be autogenerated into editable fields when the cell is double clicked. Any help or links to tutorials is appreciated. Thanks.
Add an onclick event that opens the window to the cell (using datagridview would be a good idea I think).
In addition, you you just want them to edit the cell contents, you can let the control handle all that for you (enable editing, adding, deleting, etc if you want).
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.onclick.aspx