Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2387
Determining Which Row the User Clicked
posted

What I am trying to do would seam simple, but...

I have a WinGrid that has only one band, I want the whole row to be selected when a user clicks on it.  I went into the "Feature Picker" and set:

Selection --> Row Selection to "Single Select"
Selection --> Column Selection to "Don't allow"
Selection --> Cell Selection to "Don't allow"

When I click on a cell, only the cell is selected, the caret (arrow on the left row selector) did not become active nor was the whole row selected. 

So I went off to look through the help to see if I could find something and I found an article titled "Determining Which Row the User Clicked".  I figured it was the hard way to do it, but what the heck, find the row selected and make it active and selected.  When I tried it, the MouseUp event never gets called.  I don't see anything in the article about having to flip another property to make the MouseUp event active, so I am completely stumped on both how to do what I want to do and why MouseUp doesn't ever get called.  Below is all the designer code for the WinGrid in question.

Sam

 

            this.ultraGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.ultraGrid1.DataSource = this.uSER_SECURITYBindingSource;
            this.ultraGrid1.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns;
            ultraGridColumn1.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.Append;
            ultraGridColumn1.AutoSizeMode = Infragistics.Win.UltraWinGrid.ColumnAutoSizeMode.None;
            ultraGridColumn1.Header.VisiblePosition = 0;
            ultraGridColumn1.MaxWidth = 36;
            ultraGridColumn1.MinLength = 36;
            ultraGridColumn1.MinWidth = 36;
            ultraGridColumn1.Width = 36;
            ultraGridColumn2.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.Append;
            ultraGridColumn2.Header.VisiblePosition = 1;
            ultraGridColumn2.Hidden = true;
            ultraGridColumn3.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.Append;
            ultraGridColumn3.Header.VisiblePosition = 2;
            ultraGridColumn3.Width = 141;
            ultraGridColumn4.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.Append;
            ultraGridColumn4.Header.VisiblePosition = 3;
            ultraGridColumn4.Width = 156;
            ultraGridColumn5.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.Append;
            ultraGridColumn5.Header.VisiblePosition = 4;
            ultraGridColumn5.Width = 138;
            ultraGridBand1.Columns.AddRange(new object[] {
            ultraGridColumn1,
            ultraGridColumn2,
            ultraGridColumn3,
            ultraGridColumn4,
            ultraGridColumn5});
            ultraGridBand1.RowLayoutStyle = Infragistics.Win.UltraWinGrid.RowLayoutStyle.GroupLayout;
            this.ultraGrid1.DisplayLayout.BandsSerializer.Add(ultraGridBand1);
            this.ultraGrid1.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.False;
            this.ultraGrid1.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;
            this.ultraGrid1.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
            this.ultraGrid1.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
            this.ultraGrid1.DisplayLayout.Override.SelectTypeCell = Infragistics.Win.UltraWinGrid.SelectType.None;
            this.ultraGrid1.DisplayLayout.Override.SelectTypeCol = Infragistics.Win.UltraWinGrid.SelectType.None;
            this.ultraGrid1.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Single;
            this.ultraGrid1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ultraGrid1.Location = new System.Drawing.Point(12, 12);
            this.ultraGrid1.Name = "ultraGrid1";
            this.ultraGrid1.Size = new System.Drawing.Size(492, 508);
            this.ultraGrid1.TabIndex = 9;
            this.ultraGrid1.Text = "ultraGrid1";
            this.ultraGrid1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ultraGrid1_MouseUp);
            this.ultraGrid1.AfterSelectChange += new Infragistics.Win.UltraWinGrid.AfterSelectChangeEventHandler(this.ultraGrid1_AfterSelectChange);

Parents
No Data
Reply
  • 37774
    Verified Answer
    posted

    I'm not quite sure why clicking into an individual cell is not activating the row at the same time, and nothing in your code posted strikes me as problematic.  Regardless, there is indeed an easy way to accomplish what you're going for, mainly through the use of the CellClickAction property:

    private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
    {
        e.Layout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
    }

    It's possible you're not getting the MouseUp message because the TextBox that is positioned when a cell goes into edit mode might get that message, but this may be a moot point if the CellClickAction solves your problem :-)

    -Matt

Children
No Data