Re: Move a data column in a datatable

Tech-Archive recommends: Speed Up your PC by fixing your registry



Maybe, Marina, I am asking the wrong question. How do I change the display
order?

Do you know that answer to that one?

"Marina" <someone@xxxxxxxxxx> wrote in message
news:O0I%23EPr7FHA.2624@xxxxxxxxxxxxxxxxxxxxxxx
> Ok, again, my question is, why does it matter where these columns are?
>
> If you are displaying data in a grid you should be able to control where
> what column is displayed anyway. I don't see why the actual ordering of
> the columns makes a difference.
>
> "Tim Cowan" <timc__SPAMLESS__@xxxxxxxxxxxxxx> wrote in message
> news:HWlgf.847$e43.110521@xxxxxxxxxxxxxxxxxxxxxxxx
>>I want to add two custom button columns at run time. They add just fine at
>>the end of the grid, but I want to put them next to the columns that are
>>associated with.
>>
>> Hope you can help.
>>
>> Tim
>>
>> "Marina" <someone@xxxxxxxxxx> wrote in message
>> news:OmIRw5q7FHA.3276@xxxxxxxxxxxxxxxxxxxxxxx
>>> May I ask why the orders of the columns even matters?
>>>
>>> As far as I know there is no way to move an existing column and preserve
>>> its values.
>>>
>>> "Tim" <timc@xxxxxxxxxxxxxx> wrote in message
>>> news:S9kgf.784$e43.101763@xxxxxxxxxxxxxxxxxxxxxxxx
>>>> Hi,
>>>>
>>>> I am trying to move a datacolumn in a datatable. What I have tried so
>>>> far is to create a new datacolumn set it equal to the one I want to
>>>> remove and then remove it, add another column and add it back again in
>>>> the place I want it.
>>>>
>>>> tableStyle.MappingName = "DVGlobalPrices";
>>>>
>>>> System.Data.DataColumn dCol = new DataColumn();
>>>> dCol = dvData.Table.Columns["CUR_new_price_1"];
>>>>
>>>> dvData.Table.Columns.Remove(dCol);
>>>>
>>>> if(dvData.Table.Columns["Button"] == null)
>>>> dvData.Table.Columns.Add("Button");
>>>>
>>>> dvData.Table.Columns.Add(dCol);
>>>>
>>>> However the column mapping seem to be lost as the whole column is now
>>>> displayed as (null) instead of the values.
>>>>
>>>> Is this the best way to go about it? Is there another way? I am trying
>>>> to add a column that is not in the original dataview. If I append the
>>>> column to the end of the columns collection everything works fine, but
>>>> I would like to put it before the last column in the dataview.
>>>>
>>>> Tim
>>>
>>>
>>
>>
>
>


.


Quantcast