Sign in to follow this  

[.net] Problem With DataGrid Display

This topic is 4254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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
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

This topic is 4254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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