PC Review


Reply
Thread Tools Rate Thread

The DataColumn property caption is of no use

 
 
Tony
Guest
Posts: n/a
 
      19th Dec 2011
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.

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;

//CustomerName column
column = table.Columns.Add("CustomerName",
System.Type.GetType("System.String"));
column.Caption = "Name";

//CreditLimit
column = table.Columns.Add("CreditLimit",
System.Type.GetType("System.Double"));
column.DefaultValue = 0;
column.Caption = "Limit";

table.Rows.Add(new object[] { 1, "Jonathan", 23.44 });
table.Rows.Add(new object[] { 2, "Bill", 56.87 });
}

//Tony

 
Reply With Quote
 
 
 
 
Jeff Johnson
Guest
Posts: n/a
 
      19th Dec 2011
"Tony" <(E-Mail Removed)> wrote in message
news:4eef687f$0$281$(E-Mail Removed)...

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


 
Reply With Quote
 
 
 
 
Tony
Guest
Posts: n/a
 
      19th Dec 2011

"Jeff Johnson" <(E-Mail Removed)> skrev i meddelandet
news:jcnqfk$9ma$(E-Mail Removed)...
> "Tony" <(E-Mail Removed)> wrote in message
> news:4eef687f$0$281$(E-Mail Removed)...
>
>> 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

//Tony

 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      19th Dec 2011
"Tony" <(E-Mail Removed)> wrote in message
news:4eef6f0c$0$291$(E-Mail Removed)...
>
> "Jeff Johnson" <(E-Mail Removed)> skrev i meddelandet
> news:jcnqfk$9ma$(E-Mail Removed)...
>> "Tony" <(E-Mail Removed)> wrote in message
>> news:4eef687f$0$281$(E-Mail Removed)...
>>
>>> 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.


 
Reply With Quote
 
Tony
Guest
Posts: n/a
 
      19th Dec 2011

"Jeff Johnson" <(E-Mail Removed)> skrev i meddelandet
news:jco1i6$pt1$(E-Mail Removed)...
> "Tony" <(E-Mail Removed)> wrote in message
> news:4eef6f0c$0$291$(E-Mail Removed)...
>>
>> "Jeff Johnson" <(E-Mail Removed)> skrev i meddelandet
>> news:jcnqfk$9ma$(E-Mail Removed)...
>>> "Tony" <(E-Mail Removed)> wrote in message
>>> news:4eef687f$0$281$(E-Mail Removed)...
>>>
>>>> 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

 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      19th Dec 2011
"Tony" <(E-Mail Removed)> wrote in message
news:4eef9e26$0$286$(E-Mail Removed)...

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


 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      21st Dec 2011
On 12/19/2011 3:27 PM, Tony wrote:
> "Jeff Johnson" <(E-Mail Removed)> skrev i meddelandet
> news:jco1i6$pt1$(E-Mail Removed)...
>> "Tony" <(E-Mail Removed)> wrote in message
>> news:4eef6f0c$0$291$(E-Mail Removed)...
>>>
>>> "Jeff Johnson" <(E-Mail Removed)> skrev i meddelandet
>>> news:jcnqfk$9ma$(E-Mail Removed)...
>>>> "Tony" <(E-Mail Removed)> wrote in message
>>>> news:4eef687f$0$281$(E-Mail Removed)...
>>>>
>>>>> 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

 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      21st Dec 2011
"Arne Vajh°j" <(E-Mail Removed)> wrote in message
news:4ef128e3$0$288$(E-Mail Removed)...

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


 
Reply With Quote
 
Phil Hunt
Guest
Posts: n/a
 
      21st Dec 2011
> 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 ?


 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      21st Dec 2011
"Phil Hunt" <(E-Mail Removed)> wrote in message
news:jct13p$sks$(E-Mail Removed)...

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

My guess: they intended to use it and then scrapped the idea.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataColumn.Caption property not displayed in DataGridView control =?Utf-8?B?Sm9iIExvdA==?= Microsoft Dot NET 0 16th Jan 2006 03:18 AM
DataGridView doesn't seem to honor the DataColumn.Caption Property =?Utf-8?B?T2xkbWFu?= Microsoft Dot NET Framework Forms 6 2nd Jan 2006 07:55 PM
binding datacolumn to another datacolumn in a datagrid bpdace Microsoft C# .NET 0 23rd Nov 2005 04:59 PM
How to add a datacolumn which points to another datacolumn Programatix Microsoft ADO .NET 1 30th Jan 2005 05:12 PM
Why don't DataGrid Use DataColumn.Caption madhu Microsoft ADO .NET 0 8th Nov 2003 08:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:57 PM.