Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

You got 2 options :

 

1. Add a tablestyle to your datagrid and set the width of the columns you want to hide to 0

 

2. Set those columns to hidden mapping thus they won't appear in the datagrid. Ex in VB.NET: YourDataSet.Tables("YourTable").Columns("YourColumnName").ColumnMapping = MappingType.Hidden

 

Hope this helps,

Dream as if you'll live forever, live as if you'll die today
Posted

I am sorry but I didnt understand what you meant by that.

 

Try the second method it is straight forward...

Dream as if you'll live forever, live as if you'll die today
  • *Experts*
Posted

Lopes, I really think you should spend some time playing around with the grid, reading the help files on it, etc. It will definitely pay off in the long run. Part of being a developer is learning where to find answers to common questions - and while the forums are a great help, you shouldn't skip the more accessible help files that come with .NET.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • 1 month later...
Posted

Hello Nerseus

I also was facing this problem, and your information was very helpfull. Now My problem is, using the code YourDataSet.Tables("YourTable").Columns("YourColumnName").ColumnMapping = MappingType.Hidden, I hide the specific column in the dataset table and then, bound the datagrid with the table. But I am using the value in the hidden column to get the corresponding other data in the row. The code I used is

keyid = CInt(Val(dgSettlTyp.Item(dgSettlTyp.CurrentRowIndex, 3))). The columnindex 3 is hidden.

 

The error I am getting is "Specified arguement was out of range of the valid values"

 

My requirement is I want to use the value in the column, but don't want to display it to the user. Can you help me in this.

 

Or How can I make the column widh to be zero at runtime???

 

Thank you

Posted (edited)

girilal,

 

Hi, you don't really have to hide the datagrid column in order to get a value from dataset because you can always get the value from the dataset itself.

 

However, if you prefer to set the datagrid particular column's size to 0, then, perhaps you can follow this link: http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q708q

 

pcPirate.

Edited by pcPirate

Be you his eunuch, and your mute I'll be:

When my tongue blabs, then let mine eyes not see.

Posted

Hi Pirate,

Thanks for your reply.

Lemme explane little more detail.

Actually I have two tabs. One list and one maintanance tab. The list tab contains a datagrid. Once you select a row from the list and click on maintanance you can modify that particular row. For that i need to get the data from that row and to put appropriate textboxes in maintanace tab. For getting the reference of the row i have put an Id column also in the datagrid but don't want to show the user.

 

I tried with the following type of codes.

 

Dim myGridTableStyle As DataGridTableStyle = New DataGridTableStyle

''Map the style to the dataset table.

myGridTableStyle.MappingName = SettlementRec.Tables(0).ToString

hfgSettlTyp.TableStyles.Add(myGridTableStyle)

myGridTableStyle.GridColumnStyles(0).Width = 90

myGridTableStyle.GridColumnStyles(1).Width = 90

myGridTableStyle.GridColumnStyles(2).Width = 90

myGridTableStyle.GridColumnStyles(3).Width = 0

'and with following code

 

hfgSettlTyp.TableStyles(0).GridColumnStyles(3).Width = 0

 

But I am getting an error sayin "Index out of range"

 

I have 4 colums in the datagrid table. But the error I am geting if I put column index to 0 or 1 also.

 

Can you help me in this regards...

Posted

Okay,

 

I know not much about VB.Net but I'll see what I can do. First, using the same code you provided, can you set the columns width all to 90 without any error? Otherwise, you'll have to learn the way to set the column width correctly first.

 

pcPirate.

Be you his eunuch, and your mute I'll be:

When my tongue blabs, then let mine eyes not see.

Posted

No. All the columns are taking the size which is specified in the Datafrid property. The code is not executing and givin exception "Index was out of range. Must be a non negative number or less than the size of collection" But the datagrid table contain and dataset contain 4 columns, means upto a size 3 is acceptable. right?????

 

I changed the line

myGridTableStyle.MappingName = SettlementRec.Tables(0).ToString

to

myGridTableStyle.MappingName = "SettlementMaster". Which is the table name.

 

Still the error persisting.

 

Anyway thanks for your interest and informations. I'll go ahead with my R&D for debug it. Let me know if you get any hint or clues.

 

Thanks a lot

Posted

Err, how about this???

 

Your code:

Dim myGridTableStyle As DataGridTableStyle = New DataGridTableStyle

''Map the style to the dataset table.

myGridTableStyle.MappingName = SettlementRec.Tables(0).ToString

hfgSettlTyp.TableStyles.Add(myGridTableStyle)

myGridTableStyle.GridColumnStyles(0).Width = 90

myGridTableStyle.GridColumnStyles(1).Width = 90

myGridTableStyle.GridColumnStyles(2).Width = 90

myGridTableStyle.GridColumnStyles(3).Width = 0

'and with following code

hfgSettlTyp.TableStyles(0).GridColumnStyles(3).Width = 0

 

try to change it to:

Dim ts As DataGridTableStyle = New DataGridTableStyle()

ts.MappingName = "TableName";

DataGrid1.TableStyles.Add(ts)

DataGrid1.TableStyles(0).GridColumnStyles(3).Width = 0

 

pcPirate

Be you his eunuch, and your mute I'll be:

When my tongue blabs, then let mine eyes not see.

Posted

Still it giving the error.

 

Many thanks for your interest Pirate. I solved the problem in a different way.

 

I hide the column using the code

 

SettlementRec.Tables(0).Columns("SettlementTypeID").ColumnMapping = MappingType.Hidden

 

where SettlementRec is the dataset.

 

Then in the maintanance tab section I accessed the column index used the following code.

 

keyid = CInt(SettlementRec.Tables(0).Rows(hfgSettlTyp.CurrentRowIndex).Item(3))

 

Where hfgSettlTyp is the datagrid.

 

But still I need to find that error. That I will do later..

 

Many thanks for your help and looking for your support in future also.

 

"Wish you a very very happy new year"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...