Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET Interface and Graphics > DataGrid Control...


Reply
 
Thread Tools Display Modes
  #1  
Old 04-07-2006, 08:39 AM
GForce GForce is offline
Freshman
 
Join Date: Mar 2006
Location: Pittsburgh, PA
Posts: 44
Default DataGrid Control...


I am working with a Read-Only DataGrid Control and it is giving me fits. I just want the User to select a Record from a Table using Sorting and Filtering capabilities rapidly available to DataViews and DataGrids. I therefore select the set dgTable.Select(dgTable.CurrentRowIndex) in the CurrentCellChanged Event.
The problem is that the control paints the Cell as if it were active for editing, despite the fact that the ReadOnly Property is set to True. Therefore I get a nice solid Blue Record Hightlight, interrupted by Grey/Brown Cell Active for Editing indication. Though it will not allow me to update the cell, at least that much is correct. See the attached JPEG for the Ugly user Interface...
I am new to .NET, but I have tried all the Properties I can think of, please make suggestions...
Attached Images
File Type: jpeg Ugly.JPEG (37.1 KB, 6 views)

Last edited by GForce; 04-07-2006 at 08:46 AM.
Reply With Quote
  #2  
Old 04-07-2006, 11:05 AM
torpkevuk's Avatar
torpkevuk torpkevuk is offline
Contributor
 
Join Date: Oct 2003
Location: Nebraska, USA
Posts: 640
Default

If im understanding you correctly, you want to select the row (and know which row they click) by clicking on any cell in that row?

If thats the case, this code should do it for you.

Code:
Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseUp Dim pt = New Point(e.X, e.Y) Dim hit As DataGrid.HitTestInfo = DataGrid1.HitTest(pt) If hit.Type = Windows.Forms.DataGrid.HitTestType.Cell Then DataGrid1.CurrentCell = New DataGridCell(hit.Row, hit.Column) DataGrid1.Select(hit.Row) End If MsgBox(DataGrid1.CurrentRowIndex) End Sub

Obviously, change DataGrid1 for the name of your datagrid

Hope that helps
Reply With Quote
  #3  
Old 04-07-2006, 11:58 AM
GForce GForce is offline
Freshman
 
Join Date: Mar 2006
Location: Pittsburgh, PA
Posts: 44
Default Tyvm!

Thanks... Not sure why the User Interface draws properly when you jump through hoops determining where the Mouse Pointer was within the Control when the Button was Pressed, but it does work. My original solution of DataGrid1.Select(DataGrid1.CurrentRowIndex) should have accomplished the same thing, but obviously there was a timing issue involved. It almost seems that the DataGrid is the old MSGrid Control which we used to have to chase a TextBox Control around the interior to allow Editing.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->