473,704 Members | 2,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datagrid and columnwidth

max
I am not being a smartass and would honestly like an explanation, if
you could take the time.

What's wrong with:

DataGrid.Column (0).Width = 30?
or
DataGrid.Column (2).Width = DataGrid.Width - _
(DataGrid.Colum n(0).Width + _
DataGrid.Column (1).Width) ?

Is there something wrong with simplicity?? Does this not cover all
the bases? Or possibly could it be to keep the humbled masses in there
place? Or ?

Thanks for your time,
--max
Nov 21 '05 #1
4 1411
<max> schrieb:
I am not being a smartass and would honestly like an explanation, if
you could take the time.

What's wrong with:

DataGrid.Column (0).Width = 30?


I am not very familar with the datagrid, but you may want to take a look at
the page referenced below:

<URL:http://msdn.microsoft. com/library/en-us/dv_vstechart/html/vbtchformatting windowsformsdat agridvisualbasi cprimer.asp>
-> "Setting Column Width"

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Are You Using GridColumnStyle
If not , try using that

HTH
rawCoder

<max> wrote in message news:n2******** *************** *********@4ax.c om...
I am not being a smartass and would honestly like an explanation, if
you could take the time.

What's wrong with:

DataGrid.Column (0).Width = 30?
or
DataGrid.Column (2).Width = DataGrid.Width - _
(DataGrid.Colum n(0).Width + _
DataGrid.Column (1).Width) ?

Is there something wrong with simplicity?? Does this not cover all
the bases? Or possibly could it be to keep the humbled masses in there
place? Or ?

Thanks for your time,
--max

Nov 21 '05 #3
Max,

An in my opinion very simple sample for an extended use of the table style
that I made yesterday, and changed a little bit for this message here in the
message (when there are typos)

\\\Needs only a datagrid on a form
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add( "MyColumn")
dt.LoadDataRow( New Object() {"Cor"}, True)
dt.LoadDataRow( New Object() {"Herfried"} , True)
dt.LoadDataRow( New Object() {"Crouchie"} , True)
dt.LoadDataRow( New Object() {"Ken"}, True)
dt.LoadDataRow( New Object() {"Jay"}, True)
'here start the sample
Dim ts As New DataGridTableSt yle
ts.MappingName = dt.TableName
Dim column As New DataGridTextBox Column
ts.GridColumnSt yles.Add(column )
DataGrid1.Table Styles.Add(ts)
ts.PreferredRow Height = 30
DirectCast(colu mn.TextBox, DataGridTextBox ).Font = _
New System.Drawing. Font("Arial", 14, FontStyle.Bold)
column.Alignmen t = HorizontalAlign ment.Center
column.MappingN ame = dt.Columns(0).C olumnName
column.HeaderTe xt = "Names"
column.Width = 100
DataGrid1.DataS ource = dt
End Sub
///

I hope this helps a little bit?

Cor
Nov 21 '05 #4
max
Well, I guess I was just being pissy this morning. Thanks for all of
the kind responses.

But I was questioning the nature of how we go about setting the column
width on grid. Seems to me that .Width or .ColumnWidth was pretty
straight forward, but, well, now, it takes seven steps to do what we
could do in an assignment. Is this progress??

Okay, maybe I'm still pissy, but enquiring minds want to know.

Thanks again for your time,
--max
On Wed, 20 Apr 2005 09:49:05 -0600, max wrote:
I am not being a smartass and would honestly like an explanation, if
you could take the time.

What's wrong with:

DataGrid.Column (0).Width = 30?
or
DataGrid.Column (2).Width = DataGrid.Width - _
(DataGrid.Colum n(0).Width + _
DataGrid.Column (1).Width) ?

Is there something wrong with simplicity?? Does this not cover all
the bases? Or possibly could it be to keep the humbled masses in there
place? Or ?

Thanks for your time,
--max


Nov 21 '05 #5

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

Similar topics

1
3135
by: Jakob Persson | last post by:
Hi Is there a way to program a DataGrid control to automatically adjust its columnwidth so it fits the contents of the columns. I am searching for a automated way to do the thing you do when you manually doubleclick on the columnheader. Yours truly
0
957
by: Hannes | last post by:
Hello! When doubleclicking on the columnseparator of a datagrid the columnwidth ist set to the optimal size for the instantaneous content. Is there a possibility to activate this function program-controlled for every column when displaying the grid with a new columncontent? Thank You for Your help Hannes
0
876
by: Hannes | last post by:
Hello! When doubleclicking on the columnseparator of a datagrid the columnwidth ist set to the optimal size for the instantaneous content. Is there a possibility to activate this function program-controlled for every column when displaying the grid with a new columncontent? Thank You for Your help Hannes
1
1552
by: BC | last post by:
Hi, Been searching the newgroups but haven't found an answer. I'm used to binding disconnected ADO recordsets to Datagrid controls and tweaking the Datagrid to suit my needs (columnheader, columnwidth, etc.) Now I'm using vb.net, and I'm tryint to do the same
1
1448
by: Willem | last post by:
Hi, I'm using a datagrid on a webform with 4 visible and 1 invisible columns. When clicking a button I want to make the invisible column visible. I use the code DataGrid1.Columns(4).Visible = True All fine, but the problem is that the columnwidth changes of all the columns. I would be nice if columns 1 ... 3 have the same width. So column
2
3676
by: Andrew Baker | last post by:
Coming from VB, I find the changes needed to manipulate a datagrid are much more taxing than previously. Is there a good tutorial for things like: Setting the column widths making the grid uneditable making the whole row highlight when selected There are a number of posts but as I am trying to learn on my own, they are
4
1382
by: Paul Ilacqua | last post by:
I'm filling the datagrid with no problem but I do not see a columnwidth property anywhere. How do you set the columnwidth property of the datagrid columns in code or manually? Thank you. Paul
0
2593
by: Bob Davies | last post by:
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within a dataset, however upon attempting to create tablestyles to format any of the columns within the datagrid, the exception "Can-not parent objects created on one thread to objects created on another" or words to that effect. I'm not too sure if what I said make sense, but i will add details to...
1
2776
by: Price Brattin | last post by:
How do I set the column width in a datagrid when the datasource is a dataview? I want to use a dataview so data changes, inserts, and deletes are disabled. I can set the column width when I use the DataTable that underlies the DataView as the DataSource in the DataGrid. When I use the DataTable name as the MappingName in the DataGridTableStyle, it works like a charm. However, when I change the DataGrid.DataSource to the DataView, I...
0
8767
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9026
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8977
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7891
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6605
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5931
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4439
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4701
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2483
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.