1: Make it so when the user clicks on any part of a row the FULL row
becomes selected
2: Hide the add new row from the bottom of the grid
3: Remove the grey side bar from the left of the grid
For an example see the main grid in the TaskVision Demo at:
http://www.windowsforms.net/default.aspx?tabIndex=7&tabId=44
This is the EXACT grid I want. I took a look at the source and I can't seem
to find where they made the tweaks.
The dgGrid is of type System.Windows.Forms.DataGrid so it is still the basic
grid.
I'm pretty sure it is something from the class "public sealed class
MainFormDgStyle" but I can't seem to find what.
-Jason
"Jason Hickey" <n...@spam.com> wrote in message
news:ejt84EmR...@TK2MSFTNGP11.phx.gbl...
public class SSDataGrid : DataGrid
{
private int oldSelectedRow = -1;
private bool first_click = true;
public SSDataGrid() : base()
{
CurrentCellChanged += new EventHandler(EnforceSingleSelect);
}
/// <summary>
/// select a row and scroll to it
/// </summary>
/// <remarks>
/// sets input focus to the SSDataGrid
/// </remarks>
public new void Select(int row)
{
if(oldSelectedRow >= 0)
base.UnSelect(oldSelectedRow);
base.Select(row);
base.CurrentCell = new DataGridCell(row, 1);
}
private void EnforceSingleSelect(object sender, EventArgs e)
{
if(CurrentRowIndex != oldSelectedRow && -1 != oldSelectedRow)
UnSelect(oldSelectedRow);
oldSelectedRow = CurrentRowIndex;
// select whole row
// note: endless loop avoided since Select(CurrentRowIndex) won't
send a CurrentCellChanged event
Select(CurrentRowIndex);
}
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
{
// don't call the base class if left mouse down,
// so dragging won't select multiple lines
if(e.Button != MouseButtons.Left)
base.OnMouseMove(e);
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
//don't call the base class if in header
DataGrid.HitTestInfo hti = this.HitTest(new Point(e.X, e.Y));
if(hti.Type == DataGrid.HitTestType.Cell)
{
base.OnMouseDown(e);
if(first_click)
{
EnforceSingleSelect(/*dummy*/this, /*dummy*/e);
first_click = false;
}
}
else if(hti.Type == DataGrid.HitTestType.RowHeader)
{
if((Control.ModifierKeys & Keys.Shift) == 0)
base.OnMouseDown(e);
else
this.Select(hti.Row);
-Jason
"Uri Dor" <replace_...@mivzak.com> wrote in message
news:#mOlmSsR...@tk2msftngp13.phx.gbl...
http://www.windowsforms.net/TaskVision/SourceViewer.aspx?tabindex=7&tabid=44
Want to know more? Check out the MSDN Library at http://msdn.microsoft.com or the Microsoft Knowledge Base at http://support.microsoft.com
Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : sc...@online.microsoft.com <Remove word online. from address>
This posting is provided “AS IS”, with no warranties, and confers no rights.
--------------------
>From: "Jason Hickey" <n...@spam.com>
>References: <ejt84EmR...@TK2MSFTNGP11.phx.gbl> <OqnD5ooR...@TK2MSFTNGP12.phx.gbl> <#mOlmSsR...@tk2msftngp13.phx.gbl>
>Subject: Re: Datagrid: Full Row Select and Other Options like in TaskVision
>Date: Thu, 10 Jul 2003 08:00:11 -0500
>Lines: 136
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.3790.0
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Message-ID: <#L641MuR...@TK2MSFTNGP12.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.windowsforms
>NNTP-Posting-Host: pix.broadwing.net 216.140.58.174
>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.windowsforms:48034
>X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms