Jump to content
  • Advertisement
Sign in to follow this  
Strider_Hiryu

[.net] Problem With DataGrid Display

This topic is 4473 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
Advertisement
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.ToString() == "SoftwareName")
{
MoveData = ColumnList[0].ToString();
ColumnList[0] = ColumnList.ToString();
ColumnList = MoveData.ToString();
MoveData = Conditions[0].ToString();
Conditions[0] = Conditions.ToString();
Conditions = 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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!