PC Review


Reply
Thread Tools Rate Thread

Datagrid: Full Row Select and Other Options like in TaskVision

 
 
Jason Hickey
Guest
Posts: n/a
 
      9th Jul 2003
All,
Maybe I'm just missing it but how do you do the following three things
with a WinForms DataGrid...

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....dex=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



 
Reply With Quote
 
 
 
 
Morgan
Guest
Posts: n/a
 
      10th Jul 2003
Did you look at the classes/ in the /ColumnStyles or folder? I believe it
would be in there, since so much of the layout for the datagrid derives from
the tablestyles in those classes.

"Jason Hickey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> All,
> Maybe I'm just missing it but how do you do the following three things
> with a WinForms DataGrid...
>
> 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....dex=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
>
>
>



 
Reply With Quote
 
Uri Dor
Guest
Posts: n/a
 
      10th Jul 2003
1. check out my code, which also enforces single selection (below)
2. ReadOnly = true
3. dunno

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);
}
}

}



Morgan wrote:
> Did you look at the classes/ in the /ColumnStyles or folder? I believe it
> would be in there, since so much of the layout for the datagrid derives from
> the tablestyles in those classes.
>
> "Jason Hickey" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>All,
>> Maybe I'm just missing it but how do you do the following three things
>>with a WinForms DataGrid...
>>
>> 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....dex=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
>>
>>
>>

>
>
>


 
Reply With Quote
 
Jason Hickey
Guest
Posts: n/a
 
      10th Jul 2003
1: Thought of doing something like that until I saw taskvision
application... The MS guys have done it without created a derived class
from DataGrid?!? I would like to know HOW they did it :-)
2: Duh... Thanks for that one
3: Again MS did it I would like to know the "trick". Basically it make a
data grid into a listview but with build in sort etc....

-Jason


"Uri Dor" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 1. check out my code, which also enforces single selection (below)
> 2. ReadOnly = true
> 3. dunno
>
> 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);
> }
> }
>
> }
>
>
>
> Morgan wrote:
> > Did you look at the classes/ in the /ColumnStyles or folder? I believe

it
> > would be in there, since so much of the layout for the datagrid derives

from
> > the tablestyles in those classes.
> >
> > "Jason Hickey" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >
> >>All,
> >> Maybe I'm just missing it but how do you do the following three

things
> >>with a WinForms DataGrid...
> >>
> >> 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....dex=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
> >>
> >>
> >>

> >
> >
> >

>



 
Reply With Quote
 
Scot Rose [MSFT]
Guest
Posts: n/a
 
      10th Jul 2003
The full source for TaskVision seems to be available at the web site. Is there something missing from it?

http://www.windowsforms.net/TaskVisi...dex=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 : (E-Mail Removed) <Remove word online. from address>

This posting is provided “AS IS”, with no warranties, and confers no rights.




--------------------
>From: "Jason Hickey" <(E-Mail Removed)>
>References: <(E-Mail Removed)> <(E-Mail Removed)> <#(E-Mail Removed)>
>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: <#(E-Mail Removed)>
>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
>
>1: Thought of doing something like that until I saw taskvision
>application... The MS guys have done it without created a derived class
>from DataGrid?!? I would like to know HOW they did it :-)
>2: Duh... Thanks for that one
>3: Again MS did it I would like to know the "trick". Basically it make a
>data grid into a listview but with build in sort etc....
>
> -Jason
>
>
>"Uri Dor" <(E-Mail Removed)> wrote in message
>news:#(E-Mail Removed)...
>> 1. check out my code, which also enforces single selection (below)
>> 2. ReadOnly = true
>> 3. dunno
>>
>> 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);
>> }
>> }
>>
>> }
>>
>>
>>
>> Morgan wrote:
>> > Did you look at the classes/ in the /ColumnStyles or folder? I believe

>it
>> > would be in there, since so much of the layout for the datagrid derives

>from
>> > the tablestyles in those classes.
>> >
>> > "Jason Hickey" <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> >
>> >>All,
>> >> Maybe I'm just missing it but how do you do the following three

>things
>> >>with a WinForms DataGrid...
>> >>
>> >> 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....dex=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
>> >>
>> >>
>> >>
>> >
>> >
>> >

>>

>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Full row select in datagrid =?Utf-8?B?QWJoaXNoZWsgRHdpdmVkaQ==?= Microsoft C# .NET 0 26th Nov 2004 05:35 AM
How to select a full row in datagrid? AA Microsoft VB .NET 3 6th Aug 2004 05:31 PM
Full Windows Forms Applications Like TaskVision? Eliezer Figueroa Microsoft Dot NET 1 3rd Jan 2004 04:36 AM
Full Aplications like TaskVision?? Eliezer Figueroa Microsoft Dot NET 1 2nd Jan 2004 05:27 PM
DataGrid - on WinForms Full Row Select Lord2702 Microsoft Dot NET Framework Forms 0 6th Jul 2003 08:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:31 AM.