The DataColumn property caption is of no use

I can't see any use of the property Caption in the DataColumn class because
you can't change the column title by using that property.
Here I have a short code snippet where I change the Caption on the third
added column to Limit but if I look at the
DataTable its still show the column title as CreditLimit so setting the
Caption has no effect.

I hope someone can correct me if I'm wrong about this caption property on
the DataColum class.

Advertisements

"Tony" <> wrote in message
news:4eef687f$0$281$...
> I can't see any use of the property Caption in the DataColumn class
> because you can't change the column title by using that property.
> Here I have a short code snippet where I change the Caption on the third
> added column to Limit but if I look at the
> DataTable its still show the column title as CreditLimit so setting the
> Caption has no effect.
>
> I hope someone can correct me if I'm wrong about this caption property on
> the DataColum class.

Just a guess, but this property is probably used by other code to set a
caption when autogenerating a form or report based on the DataTable,
assuming you want to use something other than the underlying column's name.
MS Access has had this capability for years. It's PURELY for display. MSDN
says this:

You can use the Caption property to display a descriptive or friendly name
for a DataColumn.

Advertisements

"Jeff Johnson" <> skrev i meddelandet
news:jcnqfk$9ma$...
> "Tony" <> wrote in message
> news:4eef687f$0$281$...
>
>> I can't see any use of the property Caption in the DataColumn class
>> because you can't change the column title by using that property.
>> Here I have a short code snippet where I change the Caption on the third
>> added column to Limit but if I look at the
>> DataTable its still show the column title as CreditLimit so setting the
>> Caption has no effect.
>>
>> I hope someone can correct me if I'm wrong about this caption property on
>> the DataColum class.
>
> Just a guess, but this property is probably used by other code to set a
> caption when autogenerating a form or report based on the DataTable,
> assuming you want to use something other than the underlying column's
> name. MS Access has had this capability for years. It's PURELY for
> display. MSDN says this:
>
> You can use the Caption property to display a descriptive or friendly name
> for a DataColumn.

It has no affect if you use it as the MSDN says like
You can use the Caption property to display a descriptive or friendly name
for a DataColumn.
If will has no effect ?
So this caption is of no use.

"Tony" <> wrote in message
news:4eef6f0c$0$291$...
>
> "Jeff Johnson" <> skrev i meddelandet
> news:jcnqfk$9ma$...
>> "Tony" <> wrote in message
>> news:4eef687f$0$281$...
>>
>>> I can't see any use of the property Caption in the DataColumn class
>>> because you can't change the column title by using that property.
>>> Here I have a short code snippet where I change the Caption on the third
>>> added column to Limit but if I look at the
>>> DataTable its still show the column title as CreditLimit so setting the
>>> Caption has no effect.
>>>
>>> I hope someone can correct me if I'm wrong about this caption property
>>> on the DataColum class.
>>
>> Just a guess, but this property is probably used by other code to set a
>> caption when autogenerating a form or report based on the DataTable,
>> assuming you want to use something other than the underlying column's
>> name. MS Access has had this capability for years. It's PURELY for
>> display. MSDN says this:
>>
>> You can use the Caption property to display a descriptive or friendly
>> name for a DataColumn.
>
> It has no affect if you use it as the MSDN says like
> You can use the Caption property to display a descriptive or friendly name
> for a DataColumn.
> If will has no effect ?
> So this caption is of no use.

How can I say it clearer? It is of use to OTHER things. If you don't use
those other things then it's meaningless FOR YOU, but not necessarily for
other people.

"Jeff Johnson" <> skrev i meddelandet
news:jco1i6$pt1$...
> "Tony" <> wrote in message
> news:4eef6f0c$0$291$...
>>
>> "Jeff Johnson" <> skrev i meddelandet
>> news:jcnqfk$9ma$...
>>> "Tony" <> wrote in message
>>> news:4eef687f$0$281$...
>>>
>>>> I can't see any use of the property Caption in the DataColumn class
>>>> because you can't change the column title by using that property.
>>>> Here I have a short code snippet where I change the Caption on the
>>>> third added column to Limit but if I look at the
>>>> DataTable its still show the column title as CreditLimit so setting the
>>>> Caption has no effect.
>>>>
>>>> I hope someone can correct me if I'm wrong about this caption property
>>>> on the DataColum class.
>>>
>>> Just a guess, but this property is probably used by other code to set a
>>> caption when autogenerating a form or report based on the DataTable,
>>> assuming you want to use something other than the underlying column's
>>> name. MS Access has had this capability for years. It's PURELY for
>>> display. MSDN says this:
>>>
>>> You can use the Caption property to display a descriptive or friendly
>>> name for a DataColumn.
>>
>> It has no affect if you use it as the MSDN says like
>> You can use the Caption property to display a descriptive or friendly
>> name
>> for a DataColumn.
>> If will has no effect ?
>> So this caption is of no use.
>
> How can I say it clearer? It is of use to OTHER things. If you don't use
> those other things then it's meaningless FOR YOU, but not necessarily for
> other people.

What I want to say is that the manual say the following
"You can use the Caption property to display a descriptive or friendly name
for a DataColumn"
So this would mean that the header for the column in a DataGridView or
DataGrid would have the name from the Caption but that is not what would
happen."

So the manual about this Caption property is completely wrong no matter what
you say.

"Tony" <> wrote in message
news:4eef9e26$0$286$...
> What I want to say is that the manual say the following
> "You can use the Caption property to display a descriptive or friendly
> name for a DataColumn"
> So this would mean that the header for the column in a DataGridView or
> DataGrid would have the name from the Caption but that is not what would
> happen."
>
> So the manual about this Caption property is completely wrong no matter
> what you say.

Okay, a quick Web search seems to indicate that this property is not used by
any built-in Microsoft controls. However, its purpose remains the same: it's
there for you to STORE a string to be used in place of the column name.
However, it seems like it's UP TO YOU to actually use this name.

I guess it's like the Tag property. Will you suggest the Tag property is
useless simply because nothing built-in to the Framework automatically uses
it?

Also, I argue that MSDN is RIGHT, but not CLEAR. (Reminds me of the old joke
about the guy in the balloon....) I says "YOU can use the Caption
property..." and it really means it: it's there for YOU, and only you,
apparently.

On 12/19/2011 3:27 PM, Tony wrote:
> "Jeff Johnson" <> skrev i meddelandet
> news:jco1i6$pt1$...
>> "Tony" <> wrote in message
>> news:4eef6f0c$0$291$...
>>>
>>> "Jeff Johnson" <> skrev i meddelandet
>>> news:jcnqfk$9ma$...
>>>> "Tony" <> wrote in message
>>>> news:4eef687f$0$281$...
>>>>
>>>>> I can't see any use of the property Caption in the DataColumn class
>>>>> because you can't change the column title by using that property.
>>>>> Here I have a short code snippet where I change the Caption on the
>>>>> third added column to Limit but if I look at the
>>>>> DataTable its still show the column title as CreditLimit so setting
>>>>> the Caption has no effect.
>>>>>
>>>>> I hope someone can correct me if I'm wrong about this caption
>>>>> property on the DataColum class.
>>>>
>>>> Just a guess, but this property is probably used by other code to
>>>> set a caption when autogenerating a form or report based on the
>>>> DataTable, assuming you want to use something other than the
>>>> underlying column's name. MS Access has had this capability for
>>>> years. It's PURELY for display. MSDN says this:
>>>>
>>>> You can use the Caption property to display a descriptive or
>>>> friendly name for a DataColumn.
>>>
>>> It has no affect if you use it as the MSDN says like
>>> You can use the Caption property to display a descriptive or friendly
>>> name
>>> for a DataColumn.
>>> If will has no effect ?
>>> So this caption is of no use.
>>
>> How can I say it clearer? It is of use to OTHER things. If you don't
>> use those other things then it's meaningless FOR YOU, but not
>> necessarily for other people.
>
> What I want to say is that the manual say the following
> "You can use the Caption property to display a descriptive or friendly
> name for a DataColumn"
> So this would mean that the header for the column in a DataGridView or
> DataGrid would have the name from the Caption but that is not what would
> happen."
>
> So the manual about this Caption property is completely wrong no matter
> what you say.

Nothing prevents you from writing the TonyGrid class that
does display that property.

Maybe there is a JeffGrid that does that.

The fact that DataGridView and DataGrid does not use it is not the
same that nothing will ever use it.

"Arne Vajhøj" <> wrote in message
news:4ef128e3$0$288$...
> Maybe there is a JeffGrid that does that.

I've never even considered writing a grid. Lots o' work! However, I did
write a "canvas" control once. It was basically a stripped-down version of
the Windows Workflow designer. Quite a bit of work went into displaying the
boxes that could be placed on the canvas, I can tell you! And the piece I
was most proud of was the "thumbnail navigator," which you use to quickly
move to parts of the canvas that aren't visible.

Writing controls is kind of cool, if you're willing to put in the time. I
applaud those who do.

"Phil Hunt" <> wrote in message
news:jct13p$sks$...
>> The fact that DataGridView and DataGrid does not use it is not the
>> same that nothing will ever use it.
>>
>> Arne
>>
>
> I am no expert with the grid. But if the DataGrid itself does not use it,
> how can it make claim that the field will be used to display as alternate.
> It is just a all-purpose property like a Tag. No ?

The trick is in the wording. The MSDN description never says that anything
WILL use this property, just that it CAN be used for such a purpose. I agree
that it SUGGESTS that something will use it, and since Microsoft shouldn't
be making claims about other people's software, that also SUGGESTS that
something Microsoft wrote will be the consumer, but that isn't the case.

"Peter Duniho" <> wrote in message
news:...
> On 12/21/11 9:21 AM, Jeff Johnson wrote:
>> [...]
>>> I am no expert with the grid. But if the DataGrid itself does not use
>>> it,
>>> how can it make claim that the field will be used to display as
>>> alternate.
>>> It is just a all-purpose property like a Tag. No ?
>>
>> The trick is in the wording. The MSDN description never says that
>> anything
>> WILL use this property, just that it CAN be used for such a purpose.
>> [...]
>
> More to the point of Phil's question: when he writes "if the DataGrid
> itself does not use it, how can it make claim.", he's falling into the
> trap of making a bogus assumption about what's claiming what.
>
> "It" (which in that statement must be the DataGrid type) does _not_ make
> any such claim. The documentation describing the Caption property isn't
> part of DataGrid at all. It's part of the DataColumn type.

Actually, I think he was being fast and loose with his pronouns. My take:

"But if the DataGrid itself does not use it [the Caption property of the
DataColumn], how can it [the DataColumn] make claim that the field [the
Caption property (not "field")] will be used to display as alternate."

> Actually, I think he was being fast and loose with his pronouns. My take:
>
> "But if the DataGrid itself does not use it [the Caption property of the
> DataColumn], how can it [the DataColumn] make claim that the field [the
> Caption property (not "field")] will be used to display as alternate."
>
> Isn't English fun?

I never read the documentation. But can someone show me a place in the
framework that uses the property to display the so called 'caption' ? Sure
you or I can use it to display, I can also use it for something else too.

"Phil Hunt" <> wrote in message
news:jctgoo$4kc$...
>> Actually, I think he was being fast and loose with his pronouns. My take:
>>
>> "But if the DataGrid itself does not use it [the Caption property of the
>> DataColumn], how can it [the DataColumn] make claim that the field [the
>> Caption property (not "field")] will be used to display as alternate."
>>
>> Isn't English fun?
>
> I never read the documentation. But can someone show me a place in the
> framework that uses the property to display the so called 'caption' ? Sure
> you or I can use it to display, I can also use it for something else too.

That's what we're saying: there doesn't seem to be any place that the
framework uses it. But we're also saying that the documentation doesn't
ACTUALLY SAY that some other part of the framework WILL use this property;
most people simply INFER that. (I certainly did, but that was mainly due to
my experience with Access. A more thorough search revealed that this
property is just...there.)

On Wed, 21 Dec 2011 16:50:39 -0500, Registered User
<> wrote:
>On Mon, 19 Dec 2011 17:37:43 +0100, "Tony"
><> wrote:
>
>>Hello!
>>
>>I can't see any use of the property Caption in the DataColumn class because
>>you can't change the column title by using that property.
>>Here I have a short code snippet where I change the Caption on the third
>>added column to Limit but if I look at the
>>DataTable its still show the column title as CreditLimit so setting the
>>Caption has no effect.
>>
>>I hope someone can correct me if I'm wrong about this caption property on
>>the DataColum class.
>>
>OK you're wrong
>>private void CreateDataTable()
>> {
>> DataTable table;
>> DataColumn column;
>>
>> table = new DataTable("Customers");
>>
>> //CustomerID column
>> column = table.Columns.Add("CustomerID",
>> System.Type.GetType("System.Int32"));
>> column.Unique = true;
>>

column = table.Columns.Add();
column.ColumnName = "CustomerName";
column.DataType = System.Type.GetType("System.String");
column.Caption = "Name";
>> //CreditLimit
>> column = table.Columns.Add("CreditLimit",
>> System.Type.GetType("System.Double"));
>> column.DefaultValue = 0;
> // this line does not set the property as expected
>> column.Caption = "Limit";
> // yet this line does set the property as expected
> table.Columns[2].Caption = "Limit";
>> table.Rows.Add(new object[] { 1, "Jonathan", 23.44 });
>> table.Rows.Add(new object[] { 2, "Bill", 56.87 });
>> }
>>
>
>Interesting, how the caption is set makes a difference.
>
I must correct myself. How the column is added to the table appears to
make the difference. When the CustomerName column is added as shown
above, the column's Caption property is set to 'Name' just as
expected.

On 12/21/2011 10:09 AM, Jeff Johnson wrote:
> "Arne Vajhøj"<> wrote in message
> news:4ef128e3$0$288$...
>> Maybe there is a JeffGrid that does that.
>
> I've never even considered writing a grid. Lots o' work! However, I did
> write a "canvas" control once. It was basically a stripped-down version of
> the Windows Workflow designer. Quite a bit of work went into displaying the
> boxes that could be placed on the canvas, I can tell you! And the piece I
> was most proud of was the "thumbnail navigator," which you use to quickly
> move to parts of the canvas that aren't visible.
>
> Writing controls is kind of cool, if you're willing to put in the time. I
> applaud those who do.

On 12/21/2011 11:22 AM, Phil Hunt wrote:
>> The fact that DataGridView and DataGrid does not use it is not the
>> same that nothing will ever use it.
>
> I am no expert with the grid. But if the DataGrid itself does not use it,
> how can it make claim that the field will be used to display as alternate.
> It is just a all-purpose property like a Tag. No ?

The docs for DataColumn states:

"You can use the Caption property to display a descriptive or friendly
name for a DataColumn."

On 12/21/2011 3:49 PM, Phil Hunt wrote:
>> Actually, I think he was being fast and loose with his pronouns. My take:
>>
>> "But if the DataGrid itself does not use it [the Caption property of the
>> DataColumn], how can it [the DataColumn] make claim that the field [the
>> Caption property (not "field")] will be used to display as alternate."
>>
>> Isn't English fun?
>
> I never read the documentation. But can someone show me a place in the
> framework that uses the property to display the so called 'caption' ? Sure
> you or I can use it to display, I can also use it for something else too.

Share This Page

Welcome to PC Review!

Hello and welcome to PC Review. We're a friendly computing community, bustling with knowledgeable members to help solve your tech questions.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask any tech support questions, or chat with the community and help others.
Sign up now!