473,406 Members | 2,467 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,406 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 2392
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.