473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Column Count

Hi,

I need to create a function that will return the number of columns in a
passed reference to a DataView.

I can find the number of columns in its underlying Data table but have not
been able to find a way of determining the column count in the DataView.

Thanks for any assistance.

Doug
Nov 21 '05 #1
8 6344
I didn't think the two could be different. How do you lose columns when you
apply the table to the dataview?

Chris
"Doug Bell" <dug@bigpond> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to create a function that will return the number of columns in a
passed reference to a DataView.

I can find the number of columns in its underlying Data table but have not
been able to find a way of determining the column count in the DataView.

Thanks for any assistance.

Doug

Nov 21 '05 #2
Chris,
Sorry, I didn't really explain that very well.

What I am trying to do is determine the number of columns displayed in a
datagrid.
The datagrid has a grid style applied to it.

Doug

"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:uq**************@TK2MSFTNGP12.phx.gbl...
I didn't think the two could be different. How do you lose columns when you apply the table to the dataview?

Chris
"Doug Bell" <dug@bigpond> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to create a function that will return the number of columns in a
passed reference to a DataView.

I can find the number of columns in its underlying Data table but have not been able to find a way of determining the column count in the DataView.

Thanks for any assistance.

Doug


Nov 21 '05 #3
Well This is strange and I don't know what's going on with it, but

Grab a hold of the TableStyles object off your datagrid after the gridstyle
is added. Then look at the Gridcolumnstyles. This holds all your columns,
but for some reason there isn't a count method on it. However it is really
there and I've used it. So the code below will give you the count, you can
also itterate through all the columns there. Anyone say why the Count
method isn't displayed in Intellisense?

Hope it helps

MessageBox.Show(DGrid.TableStyles(0).GridColumnSty les.Count())

Chris

"Doug Bell" <dug@bigpond> wrote in message
news:ef**************@tk2msftngp13.phx.gbl...
Chris,
Sorry, I didn't really explain that very well.

What I am trying to do is determine the number of columns displayed in a
datagrid.
The datagrid has a grid style applied to it.

Doug

"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:uq**************@TK2MSFTNGP12.phx.gbl...
I didn't think the two could be different. How do you lose columns when

you
apply the table to the dataview?

Chris
"Doug Bell" <dug@bigpond> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I need to create a function that will return the number of columns in a
> passed reference to a DataView.
>
> I can find the number of columns in its underlying Data table but have not > been able to find a way of determining the column count in the
> DataView.
>
> Thanks for any assistance.
>
> Doug
>
>



Nov 21 '05 #4
Thanks Chris,

That is great! And I was a little surprised there was not a count method but
did not think to try it without it being selectable from the intelisense.
Now I can build a re-usable function to size the last column to the
remaining grid width irespective of the selected grid style.

Doug

"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:OW**************@TK2MSFTNGP12.phx.gbl...
Well This is strange and I don't know what's going on with it, but

Grab a hold of the TableStyles object off your datagrid after the gridstyle is added. Then look at the Gridcolumnstyles. This holds all your columns, but for some reason there isn't a count method on it. However it is really there and I've used it. So the code below will give you the count, you can also itterate through all the columns there. Anyone say why the Count
method isn't displayed in Intellisense?

Hope it helps

MessageBox.Show(DGrid.TableStyles(0).GridColumnSty les.Count())

Chris

"Doug Bell" <dug@bigpond> wrote in message
news:ef**************@tk2msftngp13.phx.gbl...
Chris,
Sorry, I didn't really explain that very well.

What I am trying to do is determine the number of columns displayed in a
datagrid.
The datagrid has a grid style applied to it.

Doug

"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:uq**************@TK2MSFTNGP12.phx.gbl...
I didn't think the two could be different. How do you lose columns when
you
apply the table to the dataview?

Chris
"Doug Bell" <dug@bigpond> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I need to create a function that will return the number of columns in
a > passed reference to a DataView.
>
> I can find the number of columns in its underlying Data table but

have not
> been able to find a way of determining the column count in the
> DataView.
>
> Thanks for any assistance.
>
> Doug
>
>



Nov 21 '05 #5
That's an interesting idea. How are you figuring out how much space is left
on the grid for that column to fill?

Chris
"Doug Bell" <dug@bigpond> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks Chris,

That is great! And I was a little surprised there was not a count method
but
did not think to try it without it being selectable from the intelisense.
Now I can build a re-usable function to size the last column to the
remaining grid width irespective of the selected grid style.

Doug

"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:OW**************@TK2MSFTNGP12.phx.gbl...
Well This is strange and I don't know what's going on with it, but

Grab a hold of the TableStyles object off your datagrid after the

gridstyle
is added. Then look at the Gridcolumnstyles. This holds all your

columns,
but for some reason there isn't a count method on it. However it is

really
there and I've used it. So the code below will give you the count, you

can
also itterate through all the columns there. Anyone say why the Count
method isn't displayed in Intellisense?

Hope it helps

MessageBox.Show(DGrid.TableStyles(0).GridColumnSty les.Count())

Chris

"Doug Bell" <dug@bigpond> wrote in message
news:ef**************@tk2msftngp13.phx.gbl...
> Chris,
> Sorry, I didn't really explain that very well.
>
> What I am trying to do is determine the number of columns displayed in
> a
> datagrid.
> The datagrid has a grid style applied to it.
>
> Doug
>
> "Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
> wrote
> in message news:uq**************@TK2MSFTNGP12.phx.gbl...
>> I didn't think the two could be different. How do you lose columns when > you
>> apply the table to the dataview?
>>
>> Chris
>>
>>
>> "Doug Bell" <dug@bigpond> wrote in message
>> news:Op**************@TK2MSFTNGP09.phx.gbl...
>> > Hi,
>> >
>> > I need to create a function that will return the number of columns
>> > in a >> > passed reference to a DataView.
>> >
>> > I can find the number of columns in its underlying Data table but have > not
>> > been able to find a way of determining the column count in the
>> > DataView.
>> >
>> > Thanks for any assistance.
>> >
>> > Doug
>> >
>> >
>>
>>
>
>



Nov 21 '05 #6
An alternate solution is to resize all the column widths to make them larger
proportionally to their current width and the remaining blank space to fill

"Doug Bell" wrote:
Thanks Chris,

That is great! And I was a little surprised there was not a count method but
did not think to try it without it being selectable from the intelisense.
Now I can build a re-usable function to size the last column to the
remaining grid width irespective of the selected grid style.

Doug

"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:OW**************@TK2MSFTNGP12.phx.gbl...
Well This is strange and I don't know what's going on with it, but

Grab a hold of the TableStyles object off your datagrid after the

gridstyle
is added. Then look at the Gridcolumnstyles. This holds all your

columns,
but for some reason there isn't a count method on it. However it is

really
there and I've used it. So the code below will give you the count, you

can
also itterate through all the columns there. Anyone say why the Count
method isn't displayed in Intellisense?

Hope it helps

MessageBox.Show(DGrid.TableStyles(0).GridColumnSty les.Count())

Chris

"Doug Bell" <dug@bigpond> wrote in message
news:ef**************@tk2msftngp13.phx.gbl...
Chris,
Sorry, I didn't really explain that very well.

What I am trying to do is determine the number of columns displayed in a
datagrid.
The datagrid has a grid style applied to it.

Doug

"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:uq**************@TK2MSFTNGP12.phx.gbl...
> I didn't think the two could be different. How do you lose columns when you
> apply the table to the dataview?
>
> Chris
>
>
> "Doug Bell" <dug@bigpond> wrote in message
> news:Op**************@TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I need to create a function that will return the number of columns in a> > passed reference to a DataView.
> >
> > I can find the number of columns in its underlying Data table but have not
> > been able to find a way of determining the column count in the
> > DataView.
> >
> > Thanks for any assistance.
> >
> > Doug
> >
> >
>
>



Nov 21 '05 #7
Chris,
Sorry for delay, I had a guy come to fix my garage door.
I am still finding my way with Dot Net but what I am doing is:

1. get number of columns intNumCols
2. get desired width (intDesiredWidth) and Uused width (intUsedWidth)

Dim intDesiredWidth as Integer = MyGrid.Width
For each ctrl as Control In MyGrid.Controls
If TypeOf ctrl Is VScrollBar Then
If ctrl.Visible Then
intDesiredWidth = intDesiredWidth - ctrl.Width
EndIf
Exit For
EndIf
Next

intDesiredWidth=intDesiredWidth +39 'Fudge determined by trial & error 39
worked for me

Dim dv1 As DataView = CType(MyGrid.DataSource, DataView)
Dim stStyle As String = dv1.Table.TableName.ToString
Dim i as Integer = 0
Do While i <intNumCols - 1
intUsedWidth = intUsedWidth +
MyGrid.TableStyles(stStyle).GridColumnStyles(i).Wi dth
i = i + 1
Loop
intDesiredWidth = intDesiredWidth - intUsedWidth

If intDesiredWidth >0 Then
Do Until i = 0
If MyGrid.TableStyles(stStyle).GridColumnStyle(i).Wid th > 0 Then
'This is the last Visible Column
MyGrid.TableStyles(stStyle).GridColumnStyle(i).Wid th =
intDesiredWidth
ExitDo
EndIf
i = i - 1
Loop
EndIf
Doug

"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:uH**************@TK2MSFTNGP12.phx.gbl...
That's an interesting idea. How are you figuring out how much space is left on the grid for that column to fill?

Chris
"Doug Bell" <dug@bigpond> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks Chris,

That is great! And I was a little surprised there was not a count method
but
did not think to try it without it being selectable from the intelisense. Now I can build a re-usable function to size the last column to the
remaining grid width irespective of the selected grid style.

Doug

"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:OW**************@TK2MSFTNGP12.phx.gbl...
Well This is strange and I don't know what's going on with it, but

Grab a hold of the TableStyles object off your datagrid after the

gridstyle
is added. Then look at the Gridcolumnstyles. This holds all your

columns,
but for some reason there isn't a count method on it. However it is

really
there and I've used it. So the code below will give you the count, you

can
also itterate through all the columns there. Anyone say why the Count
method isn't displayed in Intellisense?

Hope it helps

MessageBox.Show(DGrid.TableStyles(0).GridColumnSty les.Count())

Chris

"Doug Bell" <dug@bigpond> wrote in message
news:ef**************@tk2msftngp13.phx.gbl...
> Chris,
> Sorry, I didn't really explain that very well.
>
> What I am trying to do is determine the number of columns displayed in > a
> datagrid.
> The datagrid has a grid style applied to it.
>
> Doug
>
> "Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com> > wrote
> in message news:uq**************@TK2MSFTNGP12.phx.gbl...
>> I didn't think the two could be different. How do you lose columns

when
> you
>> apply the table to the dataview?
>>
>> Chris
>>
>>
>> "Doug Bell" <dug@bigpond> wrote in message
>> news:Op**************@TK2MSFTNGP09.phx.gbl...
>> > Hi,
>> >
>> > I need to create a function that will return the number of columns
>> > in

a
>> > passed reference to a DataView.
>> >
>> > I can find the number of columns in its underlying Data table but

have
> not
>> > been able to find a way of determining the column count in the
>> > DataView.
>> >
>> > Thanks for any assistance.
>> >
>> > Doug
>> >
>> >
>>
>>
>
>



Nov 21 '05 #8
Dough,

When you still are looking for your original question
\\\
Dim x As Integer = dv.Table.Columns.Count
Dim y As String = dv.Table.Columns(0).ColumnName
'and any other information about a column
///

I hope this helps?

Cor
Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: LRW | last post by:
I'm doing the following to try to display queried data into verticle columns, and I'm getting odd behaviors. For example, if there are only 4 items to display, it skips item number 3: Item1 ...
2
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
17
by: keith | last post by:
I am trying to get a exact count of different distinct entries in an Access column. At first, I was trying to work with three columns, but I've narrowed it down to one to simplify it. I've searched...
1
by: jeguillo | last post by:
I am trying to retrieve the text within each cell in a datagrid in order to change the color of each cell, depending on the value within that cell. This works fine on the cells that are bound...
5
by: Silvio Matthes | last post by:
Hello, I'm new to the list and did not find a suitable answer to my question so here it is: I try to select the rows of a table where the content of a varchar-column is empty ('') and...
4
by: Steph. | last post by:
I have a List view displaying data in Detail mode with several columns. How I can get the column index the user clicked on ? (when user click on an item inside the ListView, not on a column...
1
by: jfarias | last post by:
Hello all, The problem I am having is in one of the datagrids I added a new column. When I run the application data is not shown in the new column. I am using VS.NET 2003 and am connecting to a...
1
by: Kimmo Laine | last post by:
Hi! I need to resize the last column in my listview control so that there won´t be horizontal scrollbar. Lets first create lv and add some items: listView1.View = View.Details;
2
by: redeye | last post by:
Hi All, I need to do a count of individual items in one column I call status. The status column contains only three values (‘Not Available’, Partially Available’, ‘Fully Available’). My sql...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.