473,378 Members | 1,479 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,378 software developers and data experts.

Datagrid Column resize

Hello All
I am trying to preserve the width of column in a datagrid
made by the user.

On form load i use this
<code>
Me.DataGrid2.TableStyles("artenc").GridColumnStyle s
(0).Width = 30
Me.DataGrid2.TableStyles("artenc").GridColumnStyle s
(1).Width = 30
Me.DataGrid2.TableStyles("artenc").GridColumnStyle s
(2).Width = 30
</code>
the user then resizes manually the width any columns .
Them after i update the datagrid dataset i want try to
store the current width
<code>
Dim tableStyle As DataGridTableStyle
tableStyle = New DataGridTableStyle
tableStyle.MappingName = "artenc"
Me.DataGrid2.TableStyles.Clear()
Me.DataGrid2.TableStyles.Add(tableStyle)

WidthDatagrid2(0) = Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(0).Width
WidthDatagrid2(1) = Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(1).Width
WidthDatagrid2(2) = Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(2).Width

Console.WriteLine(Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(1).Width)
Console.WriteLine(Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(1).Width)
Console.WriteLine(Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(2).Width)
Console.WriteLine(WidthDatagrid2(0))
Console.WriteLine(WidthDatagrid2(1))
Console.WriteLine(WidthDatagrid2(2))
</code>
all the console display 75 and i sure the width is not
75!?

Any suggestion on how to store the width of datagrid's
column?

Thanks

Kind Regards
Jorge

Nov 21 '05 #1
1 2388
Jorge,

Did you get this resolved? I could not find the thread
on your discussion to see if anyone answered.

I am interested because I have the same need... both to
set column width and preserve user's changing column
width on datagrids.

Thanks!

Bob Achgill
-----Original Message-----
Hello All
I am trying to preserve the width of column in a datagridmade by the user.

On form load i use this
<code>
Me.DataGrid2.TableStyles("artenc").GridColumnStyle s
(0).Width = 30
Me.DataGrid2.TableStyles("artenc").GridColumnStyle s
(1).Width = 30
Me.DataGrid2.TableStyles("artenc").GridColumnStyle s
(2).Width = 30
</code>
the user then resizes manually the width any columns .
Them after i update the datagrid dataset i want try to
store the current width
<code>
Dim tableStyle As DataGridTableStyle
tableStyle = New DataGridTableStyle
tableStyle.MappingName = "artenc"
Me.DataGrid2.TableStyles.Clear()
Me.DataGrid2.TableStyles.Add(tableStyle)

WidthDatagrid2(0) = Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(0).Width
WidthDatagrid2(1) = Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(1).Width
WidthDatagrid2(2) = Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(2).Width

Console.WriteLine(Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(1).Width)
Console.WriteLine(Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(1).Width)
Console.WriteLine(Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(2).Width)
Console.WriteLine(WidthDatagrid2(0))
Console.WriteLine(WidthDatagrid2(1))
Console.WriteLine(WidthDatagrid2(2))
</code>
all the console display 75 and i sure the width is not
75!?

Any suggestion on how to store the width of datagrid's
column?

Thanks

Kind Regards
Jorge

.

Nov 21 '05 #2

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

Similar topics

0
by: Pietje de kort | last post by:
Hello, why is the System.Windows.Forms.DataGrid so un-customizable? I am trying to build a DataGrid that will resize it's last column when there is room left over (make it fill the total...
3
by: Brad | last post by:
I'm working with a DataGrid in C#, and the user needs to be able add and remove columns from the DataGrid on the fly, without opening and closing the form. The scenario is this. I have a setup...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
3
by: Brian Mitchell | last post by:
I hate to ask this question because I'm sure it's been asked before, but how do you automatically resize the columns in a datagrid when the form is resized? Thanks!!
6
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is...
4
by: skOOb33 | last post by:
I successfully autosized the columns and rows on my Datagrid, and am now facing another issue. Having the sorting ability by clicking the column headers is key, but when I do that, it resizes all...
1
by: garyusenet | last post by:
I'm following a sql/vb tutorial which contains the following code which is meant to resize the datagrid view so that the columns take the correct width for the content within them. It doesn't...
1
by: ECD | last post by:
Hello all, I can usually find solutions to my .NET problems by searching these groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0 framework). I want to disable sorting on...
2
by: cj | last post by:
I was looking over some of my 2003 code today (see below) that loads a foxpro table via oledb connection. I used a sub "autosizecolumns" I found on the web but I never quite understood why they...
0
by: ashinamdev | last post by:
Hi I have a probelm I am using the datagrid control in my asp.net web page. I want to resize the datagrid column at runtime. User can be able to resize the column width according to his...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.