Sign in to follow this  
Strider_Hiryu

[.net] Problem With DataGrid Display

Recommended Posts

Strider_Hiryu    211
The Display of Data works fine, but what I need, is a way to re-arrange the Columns on the fly if certain Columns are selected. For example. User wants to see data from Columns 1 2 3 4 The data needs to be shown as 2 3 1 4 Any ideas?

Share this post


Link to post
Share on other sites
Krisc    494
Can you describe the problem a little better?

What d oyou mean the user wants to "see data", do you want to be able to make the columns moveable so that you can move the third column to be the first?

Share this post


Link to post
Share on other sites
Machaira    1033
We should make it a requirement to state what version of .NET one is using. [grin]

If you're using VS 2003 I don't believe the columns are moveable. You can change the order of your select statement and rebind the data to the grid.

If you're using VS 2005 and the DataGridView control just set the AllowUserToOrderColumns property to True.

Share this post


Link to post
Share on other sites
Strider_Hiryu    211
I'm using vs2k3, so yeah, unlike 2005, I can't just change the columns around(which was awesome, btw). Machaira, I actually did just make changes to the organization of the SQL statement, so now whenever the particular column is requested, it's listed as the first column.

Here's the source...



//If SoftwareName is a selected Column, then it is moved to the front.
for(int i = 0; i < ColumnList.Count; i++)
{
if(ColumnList[i].ToString() == "SoftwareName")
{
MoveData = ColumnList[0].ToString();
ColumnList[0] = ColumnList[i].ToString();
ColumnList[i] = MoveData.ToString();
MoveData = Conditions[0].ToString();
Conditions[0] = Conditions[i].ToString();
Conditions[i] = MoveData.ToString();
}
}







The information in the arrays is then added to a StringBuilder Object, which in turn is sent to a class that builds and executes the query.

Share this post


Link to post
Share on other sites
orbano    130
simply empty the columns list, and put the columns back in a different order. that should work. in vs2k5, columnstyles have an order property that you can see in the editor.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this