Is there a setting or simple code that makes a row 'selected' when the user clicks a cell in the row?
I am returning data based on grid_doubleclick and the first thing I check is
If dg.DisplayLayout.SelectedRows.Count = 0 Then
Exit Sub
End If
to make sure they have selected a valid row.
I found that this:
If dgRecipList.DisplayLayout.ActiveRow Is Nothing Then
dgRecipList.DisplayLayout.ActiveRow.Selected = True
txtSelectID.Text = dgRecipList.DisplayLayout.SelectedRows.Item(0).Cells(1).ToString()
txtRecip.Text = dgRecipList.DisplayLayout.SelectedRows.Item(0).Cells(0).ToString()
Worked best for me. it handles clicking on any cell or row selector, while ignoring everything else.
Thanks for you help.
yes that helps....
what I did before your response was this..
that checks the row and if nothing then exits, otherwise it selects it then I can grab the cell data. I will look at your suggestion and see if I can improve the code.
Thanks
darylleger said:you said datagrid.activerow however all i can see is displaylayout.activerow.I tried this without the desired results. I am showing row selectors on the grid.
I am showing row selectors on the grid.
You're correct - I did mean the grids' DisplayLayout.ActiveRow property.
In what way did this not get the result you were after?
Another idea: I assume you're handling the grid's server-side DblClick event? If so, then e.Cell will be the cell you double-clicked (or null, if you double-clicked elsewhere on the grid). If this is not null, then e.Cell.Row is the row that contains the cell you double-clicked. Does this help?
you said datagrid.activerow however all i can see is displaylayout.activerow.I tried this without the desired results.
The full grid setup is below.
Height="78%" StyleSetName="Default" Width="100%">
<bands>
CellClickAction="CellSelect" ColHeadersVisible="Yes" DefaultColWidth="100px"
ColFootersVisible="Yes">
<Columns>
<igtbl:UltraGridColumn BaseColumnName="fullname" Key="fullname" Width="200px">
<Header Caption="Name">
</Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn BaseColumnName="EMPID" Key="EMPID" SortingAlgorithm="NotSet">
<Header Caption="ID">
<RowLayoutColumnInfo OriginX="1" />
<Footer>
</Footer>
<igtbl:UltraGridColumn BaseColumnName="recipvar1" Key="recipvar1">
<Header Caption="recipvar1">
<RowLayoutColumnInfo OriginX="2" />
<igtbl:UltraGridColumn BaseColumnName="recipvar2" Key="recipvar2">
<Header Caption="recipvar2">
<RowLayoutColumnInfo OriginX="3" />
<igtbl:UltraGridColumn BaseColumnName="recipvar3" Hidden="True" Key="recipvar3">
<Header Caption="recipvar3">
<RowLayoutColumnInfo OriginX="4" />
<igtbl:UltraGridColumn BaseColumnName="recipvar4" Hidden="True" Key="recipvar4">
<Header Caption="recipvar4">
<RowLayoutColumnInfo OriginX="5" />
<igtbl:UltraGridColumn BaseColumnName="recipvar5" Hidden="True" Key="recipvar5">
<Header Caption="recipvar5">
<RowLayoutColumnInfo OriginX="6" />
<igtbl:UltraGridColumn BaseColumnName="recipvar6" Hidden="True" Key="recipvar6">
<Header Caption="recipvar6">
<RowLayoutColumnInfo OriginX="7" />
<igtbl:UltraGridColumn BaseColumnName="recipvar7" Hidden="True" Key="recipvar7">
<Header Caption="recipvar7">
<RowLayoutColumnInfo OriginX="8" />
<igtbl:UltraGridColumn BaseColumnName="recipvar8" Hidden="True" Key="recipvar8">
<Header Caption="recipvar8">
<RowLayoutColumnInfo OriginX="9" />
<igtbl:UltraGridColumn BaseColumnName="recipvar9" Hidden="True" Key="recipvar9">
<Header Caption="recipvar9">
<RowLayoutColumnInfo OriginX="10" />
Key="recipvar10">
<Header Caption="recipvar10">
<RowLayoutColumnInfo OriginX="11" />
</Columns>
</igtbl:UltraGridBand>
</bands>
ColWidthDefault="200px" EnableInternalRowsManagement="True"
rowheightdefault="15px" rowsrange="20" SelectTypeCellDefault="NotSet"
stationarymargins="Header" tablelayout="Fixed"
ColFootersVisibleDefault="Yes" ViewType="OutlookGroupBy"
CellClickActionDefault="RowSelect">
height="78%" width="100%" BorderColor="Black" BorderStyle="Solid">
</framestyle>
</displaylayout>
</igtbl:UltraWebGrid>
You might be able to look at the grid's "active" row instead, particularly if you only expect to otherwise have one "selected" row at a time. In other words, you might want to look at "dgRecipList.ActiveRow" instead of "dgRecipList.DisplayLayout.SelectedRows".
If you aren't showing your row selectors, then clicking on a cell won't automatically "select" the row, but it will "activate" both the row and the cell. You could probably write JavaScript to "select" a corresponding row whenever a cell is activated, especially since you're only allowing single-row selection at a time - but that sounds like it would be more work than what you may need.