Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
AnswerRe: regex search [Solved!] Pin
jojoba2026-Aug-13 7:07
jojoba2026-Aug-13 7:07 
QuestionCheckBoxlist Select ALl Pin
pavithrasubbareddy26-Aug-13 2:25
pavithrasubbareddy26-Aug-13 2:25 
AnswerRe: CheckBoxlist Select ALl Pin
SaqibRasheed26-Aug-13 5:16
SaqibRasheed26-Aug-13 5:16 
AnswerRe: CheckBoxlist Select ALl Pin
Mycroft Holmes26-Aug-13 13:03
professionalMycroft Holmes26-Aug-13 13:03 
QuestionC# Devexpress Row Select Pin
Msdx4526-Aug-13 0:44
Msdx4526-Aug-13 0:44 
AnswerRe: C# Devexpress Row Select Pin
Jason Gleim26-Aug-13 8:49
professionalJason Gleim26-Aug-13 8:49 
GeneralRe: C# Devexpress Row Select Pin
Msdx4526-Aug-13 15:49
Msdx4526-Aug-13 15:49 
GeneralRe: C# Devexpress Row Select Pin
Jason Gleim27-Aug-13 4:52
professionalJason Gleim27-Aug-13 4:52 
Oops... sorry about that. That is the xaml for a WPF or Silverlight application. However, the principles are the same, you just have to do them in the code. You need to know what you named the grid and what you named the view attached to the grid. The view will be either a TableView or a TreeView. Assuming you are calling the grid 'myGrid' and using a TreeView called 'myTreeView' the following code will deselect any selected rows and then select the row you specify by index:

C#
private void myTreeView_SelectRow(int selectRowHandle)
{
    // Check to see if any rows are selected...
    if (myTreeView.SelectedRows.Count > 0)
    {
        // The user has selected one or more rows...
        int[] rowHandles = myTreeView.GetSelectedRowHandles();
        for (int i = 0; i <= rowHandles.Length - 1; i++)
        {
            myTreeView.UnselectRow(rowHandles[i]);
        }     
    }
    myTreeView.SelectRow(selectRowHandle);
}


Of course, the selectRowHandle has to be a valid row handle. The row handles are internal row identifiers which are not always in order. The user may sort or filter the data in the grid which changes the presentation. However, the row handles will always stay the same matching up to the row they originally pointed at regardless of how the user changes the way the data is displayed.

You can get the row handle by passing the desired row object to
C#
myTreeView.GetRowHandleByTreeElement(rowObject);

So you might write something like:
C#
int selectRowHandle = myTreeView.GetRowHandleByTreeElement(dataCollection[0]);

where dataCollection is your array or collection of data objects that the grid is populated with.


Another useful function is to know if the user had selected a row. If you want to know that, you have to hook the SelectionChanged property of the TreeView:

C#
myTreeView.SelectionChanged += new GridSelectionChangedEventHandler(myTreeView_SelectionChanged);


The GridSelectionChangedEventArgs parameter of that event handler exposes a "ControllerRow" property which is the row that the user clicked. You can also use the GetSelectedRowHandles as illustrated above to get all of the selected rows in response to the user's click.

Hope that helps!
Jason
GeneralRe: C# Devexpress Row Select Pin
Msdx4531-Aug-13 12:53
Msdx4531-Aug-13 12:53 
QuestionDownload multiple files Pin
cdpsource25-Aug-13 20:55
cdpsource25-Aug-13 20:55 
AnswerRe: Download multiple files Pin
Bernhard Hiller25-Aug-13 21:04
Bernhard Hiller25-Aug-13 21:04 
GeneralRe: Download multiple files Pin
harold aptroot25-Aug-13 21:59
harold aptroot25-Aug-13 21:59 
QuestionInitializing a Class Property Pin
s.leveel25-Aug-13 9:24
s.leveel25-Aug-13 9:24 
AnswerRe: Initializing a Class Property Pin
BillWoodruff25-Aug-13 13:40
professionalBillWoodruff25-Aug-13 13:40 
RantRe: Initializing a Class Property Pin
Pete O'Hanlon25-Aug-13 21:29
mvePete O'Hanlon25-Aug-13 21:29 
AnswerRe: Initializing a Class Property Pin
Bernhard Hiller25-Aug-13 21:12
Bernhard Hiller25-Aug-13 21:12 
QuestionHow to bind SQL date to RadHtmlChart control? Pin
Member 1023043024-Aug-13 22:13
Member 1023043024-Aug-13 22:13 
AnswerRe: How to bind SQL date to RadHtmlChart control? Pin
Mycroft Holmes25-Aug-13 0:53
professionalMycroft Holmes25-Aug-13 0:53 
QuestionHow to change BG color of tree node on click event Pin
rfresh24-Aug-13 6:51
rfresh24-Aug-13 6:51 
AnswerRe: How to change BG color of tree node on click event Pin
Mycroft Holmes24-Aug-13 13:37
professionalMycroft Holmes24-Aug-13 13:37 
GeneralRe: How to change BG color of tree node on click event Pin
rfresh24-Aug-13 16:07
rfresh24-Aug-13 16:07 
GeneralRe: How to change BG color of tree node on click event Pin
rfresh24-Aug-13 18:16
rfresh24-Aug-13 18:16 
GeneralRe: How to change BG color of tree node on click event Pin
rfresh24-Aug-13 18:20
rfresh24-Aug-13 18:20 
AnswerRe: How to change BG color of tree node on click event Pin
BillWoodruff24-Aug-13 14:40
professionalBillWoodruff24-Aug-13 14:40 
GeneralRe: How to change BG color of tree node on click event Pin
rfresh24-Aug-13 16:16
rfresh24-Aug-13 16:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.