View Full Version : C# Datagrid Help
PackerFanatic
01-09-2006, 10:28 AM
Hey guys and gals, I am having some trouble finding help online with a quirky thing I am trying to do in C#, so maybe some programming guru out there can help me. I wish to retrieve the row number of a datagrid row based on the currently selected (or focused, more like) cell. What I basically want to do is based on whatever row is currently being edited, update further information in that row. I can further explain this for someone if they have a small idea as to lead me in the right direction. Thanks!
gstelmack
01-09-2006, 10:37 AM
.NET 1.0 or 2.0? Web or Forms?
There should be a "SelectedItem" or somesuch property of DataGrid. I'm trying to check online help now...
Ah, I see a "CurrentRowIndex" property.
Or there is "CurrentCell" which returns a "DataGridCell" which has "ColumnNumber" and "RowNumber" properties.
All of that is Windows Forms. Web controls don't have as rich an environment (at least in 1.0), so you're stuck with "SelectedIndex" and possibly iterating over child bits to get more details.
I don't have the 2.0 docs at work so I can't check that here.
The MSDN library is your friend (msdn.microsoft.com). All the bits above I got in about 2 minutes checking the on-line VS.NET 2003 documentation I have installed here, but the same stuff is available on-line if you're working outside of VS.NET.
PackerFanatic
01-09-2006, 10:40 AM
1.0 Forms.
Thanks for finding that, not sure why I never even though of the CurrentCell. I will have to check that out, thanks a lot!
PackerFanatic
01-10-2006, 08:45 AM
Another question...I have been looking around and it seems that many people have this issue. I want to right-align the text in my column but left-align the header text. Is there a fairly simple way to do this or will it involve many overrides and all that?
gstelmack
01-10-2006, 09:08 AM
Another question...I have been looking around and it seems that many people have this issue. I want to right-align the text in my column but left-align the header text. Is there a fairly simple way to do this or will it involve many overrides and all that?That I have no clue on.
PackerFanatic
01-10-2006, 09:24 AM
Damn, you failed me!
Haha, just kidding, the help you gave me yesterday really helped. This problem seems to be a little more tricky, sometimes .NET confuses me on their logic...
vBulletin v3.6.0, Copyright ©2000-2026, Jelsoft Enterprises Ltd.