Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2005

Tip: Looking for answers? Try searching our database.

Datagrid multiple select

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gav - 31 Aug 2005 11:08 GMT
Hi all,

I have put some code in the mouseup event for my datagrid in order to select
the entire row.

Does anybody know how I can get multiple selection to work on my datagrid?

thanks
Gav
Tim_Mac - 01 Sep 2005 15:22 GMT
hi Gav,
i use the built-in multiple select by just holding down Ctrl while i click
on the left margin of each row.
is this what you want?

tim

--------------------------
blog: http://tim.mackey.ie 
Gav - 06 Sep 2005 12:58 GMT
This is the behaviour that I'm after yes however i do not show the row
headers...

> hi Gav,
> i use the built-in multiple select by just holding down Ctrl while i click
[quoted text clipped - 5 lines]
> --------------------------
> blog: http://tim.mackey.ie
Tim_Mac - 06 Sep 2005 18:49 GMT
hi Gav,
may i ask what is your reason for hiding the row headers?
you are re-creating functionality that is already there, and requiring the
users to learn a non-standard way of selecting a row.  most users will be
familiar with the row-header way with excel.  you must have a special case
for doing this?
i don't want to be a smart a.s but before i/we try and help answer the
question, it would be good to know the reasoning behind your course of
action.
did you try setting the width of the rowheader to 15 pixels? this makes it
much less obtrusive in terms of screen space.

tim

--------------------------
blog: http://tim.mackey.ie

> This is the behaviour that I'm after yes however i do not show the row
> headers...
[quoted text clipped - 8 lines]
>> --------------------------
>> blog: http://tim.mackey.ie
Gav - 08 Sep 2005 17:21 GMT
Why would this be a 'non-standard way of selecting a row' this is how all
listview controls work, look at the inbox of outlook/outlook express you
have a list (with no column headers) which you can hold CTRL and click on
multiple rows to select them.

I guess I could have looked into making a editable ListView but that seems
like a lot more work because the datagrid looks just the same when you hide
the row headers, caption, set the back colour to white etc, then you already
have a listview look that you can edit.

Gavin

> hi Gav,
> may i ask what is your reason for hiding the row headers?
[quoted text clipped - 25 lines]
>>> --------------------------
>>> blog: http://tim.mackey.ie
Gav - 08 Sep 2005 18:29 GMT
A good example of what I'm looking for is the Library list in Windows media
player 10...

> Why would this be a 'non-standard way of selecting a row' this is how all
> listview controls work, look at the inbox of outlook/outlook express you
[quoted text clipped - 37 lines]
>>>> --------------------------
>>>> blog: http://tim.mackey.ie
Tim_Mac - 08 Sep 2005 20:04 GMT
hi Gav,
sorry i didn't know you were using the datagrid to look and behave like a
listview.  in the normal datagrid situation, it would be non-standard.

to be honest, i think the listview is the one you want.  the WM10 library
list is a listview.  you can set LabelEdit = true, View=Details.  you've got
your multi-select built in, column sorting, etc.
i couldn't get the items to BeginEdit() reliably on SelectedIndexChanged for
some reason, it would flicker editable and then return to normal.  will your
users want to edit the text just by selecting an item in the list, or will
the normal listview renaming functionality be sufficient?

tim

--------------------------
blog: http://tim.mackey.ie

> Why would this be a 'non-standard way of selecting a row' this is how all
> listview controls work, look at the inbox of outlook/outlook express you
[quoted text clipped - 37 lines]
>>>> --------------------------
>>>> blog: http://tim.mackey.ie
Gav - 12 Sep 2005 09:28 GMT
Sorry to be a pain, I know your trying to help, but I do not like the idea
of doing it this way, you cannot bind a datasource to a listview like you
can a datagrid, that was another reason for me to use datagrids over
listview they are easier to use at design time.

I still would have much prefered an answer to my original question, is it
not possible to caption in the onclick that the ctrl key is being held and
multiple select in that way?

Thanks
Gav

> hi Gav,
> sorry i didn't know you were using the datagrid to look and behave like a
[quoted text clipped - 54 lines]
>>>>> --------------------------
>>>>> blog: http://tim.mackey.ie
Tim_Mac - 13 Sep 2005 19:09 GMT
hi Gav,
you're right. i should have just trusted that you knew what you wanted!
i got this code to behave as you have described
private void dataGrid1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
   if((Control.ModifierKeys & Keys.Control) == Keys.Control)
       this.dataGrid1.Select(this.dataGrid1.CurrentRowIndex);
}

interestingly this code in MouseDown wouldn't select the row. also
datagrid_Click didn't fire for clicks inside the cells.

hope this works for you.
tim
Gav - 15 Sep 2005 16:52 GMT
Thanks for the reply I thought I had been forgotten about for a moment
there...

I have tried this out and all it seems to do is select the whole row that I
click on when I hold down CTRL, it doesn't seem to still keep the selection
on the other rows.

Thanks again
Gav

> hi Gav,
> you're right. i should have just trusted that you knew what you wanted!
[quoted text clipped - 11 lines]
> hope this works for you.
> tim
Tim_Mac - 16 Sep 2005 16:34 GMT
hi Gav,
sorry i thought your original request was just to select the whole row.  i
lost track of it with all the posts.

i'm all out of inspiration, except to suggest this control i just found:
http://www.csharphelp.com/archives2/archive341.html. it is an editable
listview control, with Ctrl+click multi select.

if that doesn't work you could try a repost, stating that you have removed
the rowheaders of a datagrid, but want to multi-select using Ctrl + click.

good luck
tim

--------------------------
blog: http://tim.mackey.ie 
mikemeamail@net2000.ch - 22 Sep 2005 10:24 GMT
Hi Gav,

I'm actually encountering the same problem as yours, meaning i want to
be able to let users select multiple rows on a datagrid without showing
the
rowheaders with the row selector represented by an arrow.
Could you find any solution to your problem ?
Regards,
Mike

> hi Gav,
> sorry i thought your original request was just to select the whole row.  i
[quoted text clipped - 12 lines]
> --------------------------
> blog: http://tim.mackey.ie
Gav - 23 Sep 2005 13:46 GMT
Sorry Mike, I do not have a solution as of yet, but I will surely let you
know when I do.

Regards
Gav

> Hi Gav,
>
[quoted text clipped - 25 lines]
>> --------------------------
>> blog: http://tim.mackey.ie
Tim_Mac - 26 Sep 2005 21:35 GMT
hi gav, did that control not serve your purposes?
http://www.csharphelp.com/archives2/archive341.html
i downloaded and tried it out and it seemed to do what you wanted.

tim

--------------------------
blog: http://tim.mackey.ie 

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.