|
-
Aug 1st, 2007, 03:11 PM
#1
Thread Starter
Addicted Member
[RESOLVED] [2005] rows like columns and columns like rows in dgw?
Hi,
I know that the title is not good but I didnt find a better one. My question is, is it possible to show datagridview columns as rows.
normally it is like this:
Age Name
34 Jack
23 Linda
... ...
But I dont have enough height to display long 2 columns and I thought maybe a formation like this would be better:
Age 34 32
Name Jack Linda
These values are only examples. Is it possible to tell dgw to show these values so?
Thanks for any help... I cant find anything about this in google...
-
Aug 1st, 2007, 03:12 PM
#2
Re: [2005] rows like columns and columns like rows in dgw?
Try using a FormView control. This will only retrieve one DataRow at a time, but it binds each value to an object in the FormView, which you can format as you please.
-
Aug 2nd, 2007, 06:55 AM
#3
Thread Starter
Addicted Member
Re: [2005] rows like columns and columns like rows in dgw?
there is only a formview which is a webcontrol acn I use it in my forms? it is added as a .net component but I cant see it in my toolbox...
-
Aug 2nd, 2007, 07:13 AM
#4
Re: [2005] rows like columns and columns like rows in dgw?
If your datagridview is just for displaying records (readonly), you can create a rotated datatable from the original datatable and bind that to your DGV and be done with it. However, if you also allow editing on the DGV then you must remember to rorate the binded datable back every time you do an update to your database. I've never done it but theretically it should work.
-
Aug 2nd, 2007, 08:19 AM
#5
Thread Starter
Addicted Member
Re: [2005] rows like columns and columns like rows in dgw?
it is programmatically editable user cant edit that. There are some buttons which edits the data. So I think it will work. But I cant see the values on my second datagridview. Because of the structure of my application it is better to take all values first to a datagrdiview and then rotate and put it toanother one. So I have written a sub for this:
vb Code:
Public Sub Rotate(ByVal Source As DataGridView, ByVal Destination As DataGridView)
Dim i As Integer
For i = 0 To Source.Rows.Count - 1
Destination.Columns.Add(i, "")
Next
For i = 0 To Source.Columns.Count - 1
Destination.Rows.Add()
Next
For i = 0 To Source.Rows.Count - 1
Destination.Rows(0).Cells(i).Value = Source.Rows(i).Cells(1).FormattedValue
Destination.Rows(1).Cells(i).Value = Source.Rows(i).Cells(0).FormattedValue
Next
End Sub
the problem is that the second DGV is empty. it has columns and rows as needed but cells dont have values. I think there is something wrong with 3rd for statement.
Edit:
Ok I did it. I have changed the virtual mode to false and it worked Thanks guys...
Last edited by Genom; Aug 2nd, 2007 at 09:08 AM.
Dim Me As Coder
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|