Results 1 to 2 of 2

Thread: Datagrid: Selected Cell

  1. #1

    Thread Starter
    Addicted Member DJ_Catboy's Avatar
    Join Date
    Jan 2003
    Location
    Suffolk, UK
    Posts
    159

    Datagrid: Selected Cell

    Hi,

    I have a datagrid. I have some code to select the entire row if a cell is clicked on:

    Code:
    dataGrid1.Select(dataGrid1.CurrentCell.RowNumber);
    When this fires, it does select the entire row, but it also leaves the cursor in the selected cell and the background colour changes and basically looks rubbish.

    I cant think of a way to stop this - I want the behaviour to be the same as clicking on a row header (which I have hidden for this excercise).

    Please can somebody help me???

    Thanks,
    DJ

  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Not sure i understand your problem, but here is how i select a row. If its not what you are looking for, please ignore this post.

    Change the dgContact to your datagrid name, and paste this in your project.

    Code:
    		private void dgContact_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    		{
    			System.Drawing.Point pt = new Point(e.X, e.Y); 			
    			
    			DataGrid.HitTestInfo hti = dgContact.HitTest(pt); 
     
    			if(hti.Type == DataGrid.HitTestType.Cell) 
     
    			{ 
     
    				dgContact.CurrentCell = new DataGridCell(hti.Row, hti.Column); 
     
    				dgContact.Select(hti.Row); 
     
    			} 
    
    		}
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width