how disable gridview header in C#? - header

How we can disable gridView headers that Users cant click on them!?
actualy I emplemented the selectinChange event gridview. but when user click on the header, it makes error... because I read the current row in selectionChange event. how can I fixed it?
thanks

Check the row index for a valid number. If the header is selected the row number is likely to be 0 or -1 (test the actual value yourself). All you then have to do is a simple check in the event handler, something like:
if (rowIndex <= 0) // Or some condition you work out for yourself.
return; // Return because this is the header row.
I hope this helps.

Related

wxPropertyGrid::EditorValidate() always returns true

A user is editing a value in a property grid, then he clicks a button outside the property grid which executes code to read the property values. Sometimes the OLD value of the property is read, rather than the new value which was being edited. I have to tell the users that they must complete the editing, by hitting return or clicking on another property before clicking any buttons outside the grid. They forget, and report a bug.
I would like to make this foolproof. Perhaps by forcing the current edit to complete when the mouse leaves the property grid.
I know how to handle the mouse leaving event. I do not know how to force the property grid to accept any partial edits.
I have tried, as a hint to the user,
pg = new wxPropertyGrid( ...
....
if( ! pg->EditorValidate() )
{
SetStatusText("Please complete editing");
return;
}
but EditorValidate() always returns true
Found it!
wxPropertyGrid::CommitChangesFromEditor()
http://docs.wxwidgets.org/trunk/classwx_property_grid.html#a6e06d92a622237457fea00372df1eaae

Programmatically set dgrid row as active

I'm trying to programmatically set a dgrid row as active, not just selected. I have a dojo dgrid OnDemandList which is using the Selection and Keyboard Mixins.
Using the select(row) method I can programmatically select a given row, but that row is not active. When a row is active, I can use the Up and Down arrow keys to navigate to the rows above and below it. When a row is just selected, the row is highlighted but the arrows keys do not work.
Clicking the row with the mouse will make it active and selected, but I'm trying to build my interface to be 100% usable with just the keyboard.
Ok, took me awhile but got it figured out. What I was really trying to do was add focus to a row. The code for doing that was in dgrid/Keyboard.js under the _focusOnNode method.
The actual code to change focus from row currentFocusedNode to row focusedNode is:
if(currentFocusedNode){
// Clean up previously-focused element
// Remove the class name and the tabIndex attribute
put(currentFocusedNode, "!dgrid-focus[!tabIndex]");
if(has("ie") < 8){
// Clean up after workaround below (for non-input cases)
currentFocusedNode.style.position = "";
}
}
if(has("ie") < 8){
// setting the position to relative magically makes the outline
// work properly for focusing later on with old IE.
// (can't be done a priori with CSS or screws up the entire table)
focusedNode.style.position = "relative";
}
focusedNode.tabIndex = grid.tabIndex;
focusedNode.focus();
put(focusedNode, ".dgrid-focus");
The code above is really just a code fragment, for it to work you will have to declare "dojo/has" and "put-selector/put" first as well as define the currentFocusedNode and focusedNode. But I'm leaving that as an exercise for the reader ;-)
Also note that this only changes the "focus", it will not select the focusedNode but that can easily be done using grid.select(focusedNode);

Hide row if it is not on the first page

I want to hide a row of a table if it is not rendered on the first page of a report. The table (tablix) is in the header nor in the footer area.
I have tried to set an expression for the RowVisibility-property, something like:
(hidden) =Globals!PageNumber<>1
however, this leads to an exception saying that the PageNumber can only be used from within the header or the footer area.
Is there a possibility to check (in an expression) if an element is located on the first page of a report?
Not a precise answer to my question, but maybe it helps someone with a similar issue:
For the tablix activate the repeat row header option
In the advance row group options, activate the option RepeatOnNewPage
For the rows that should not be shown on the next page, disable the option KeepWithGroup
I don't understand why I can not set RepeatOnNewPage only for some but not for all rows, but with the KeepWithGroup option, it seems to work like I desired.
If someone has a more precise answer to my original question, please post it. I will the change the accept to your answer!
Set this in the visibility property and the row will rendered or not depeding of the YourDatasetField value.
=IIF(True = Fields!YourDatasetField.Value, False, True)

How can I force entry to complete in a NSTextField from a NSButton

I just noticed a problem when my user-interface is in a certain state. I have a table view with two columns both of which the user can enter data that is to be used later. There's also a button which acts upon the contents of the table view.
The problem is if the user has entered new data in the column but has not yet exited the field by using the tab key or return key (i.e. the cursor is still in the field and in editing mode) and the button is pressed the old value is used not the current value sitting in the field.
What is the best way to handle this this? I want to use whatever the user has entered thus far.
Basically, The button code needs to tell the text field to finish completion or exit the editing mode. But I can't seem to find a method that will do that.
Use bindings. In Interface Builder, select the table column and in the Inspector go to Table Column Bindings and set the Value content binding appropriately and ensure the "Continuously Updates Values" option is checked. Then changes to the table cell content will propagate immediately.
Found the answer, At least for me.
Find out if a row is selected and if so deselect it. This causes the current entry to be completed.
- (void) completeTableEntry
{
// If a column is selected ensure it is completed
NSInteger sr = [keyValueTable selectedRow];
if (sr != -1) {
[keyValueTable deselectRow:sr];
}
}
How about:
[theTargetWindowWhateverThatIs endEditingFor:nil];
theTargetWindowWhateverThatIs may be, for example, self.window if you are inside a NSWindowController.

Setting Focus on DataGridView Control programmatically in Visual Basic

I want to programmatically set the focus to the last row (bottommost, its only one column wide) in the DataGridView control for Visual Basic. How can I do so?
So far, I have tried
DGV.Rows.GetLastRow(DataGridViewElementStates.Selected)
without success, though I did not expect that to work.
It absolutely must select that last cell. Otherwise, the application is nearly impossible to use!
Here is a screenshot of what I am making with this: http://www.mediafire.com/?mmyogzytgzt
The "Paste Clipboard Contents" button only pastes into the selected cell, though I guess I could find a workaround.
I solved it. I used a workaround to add the text in directly. I don't need this anymore!
To select the last column, last row in c# (sorry I don't have a vb project I'm working right now:
this._dg.ClearSelection(); // eliminates what they already have selected if you need
this._dg[this._dg.ColumnCount-1, this._dg.RowCount-1].Selected = true;
In VB.net replace 'this' with 'me', and [] with ().
This is also useful:
this._dg.Focus();
this._dg.CurrentCell = this._dg[this._dg.ColumnCount - 1, this._dg.RowCount - 1];
this._dg.BeginEdit(false); // true if you want all text highlighted
// for deletion or replacement