473,574 Members | 2,941 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Manipulating a datagrid?

I'm using Visual Studio .NET 2003 (using C#).

On a form I have a datagrid where I've set the DataSource and
DataMember to receive values
from a view in a SQL 2000 database. It works fine.

However, I do want to change individual column's width.

Now I'v defined DataGridTableSt yle Collection for each column, and I've
DataGridColumnS tyle Collection for each DataGridTableSt yle.

I've set the respective widths but at run time it gives the default
width (preferredColum nWidth)
for each column.

Do I need to produce any code to manipulate the settings I've done?

I have like (for the first column):

dtgtsFirstCol //DataGridTableSt yle


dttbFirstCol //DataGridColumnS tyle

Anybody that could guide me on this?


Dec 7 '05 #1
2 1593

I solved the problem. It's all a matter of investigating the property

I set the preferredColumn Width to 150

and the RowheaderWidth to 0

However, grid refused to accept any smaller width than 15, but I got
the desired result.


Dec 7 '05 #2

I finally solved the mystery by setting the column widths.

Here is what I did:

I made a view with data from three tables and put it on the server in a
SQL database.

Then in my application on the form containing the datagrid I did the

Choose -> TableStyles. Add a member and give it a name.

Make sure you set the RowHeadersVisib le to false
(this will make the default column of the grid invisible),
if you don't want to
have the default column of the grid to show.

Set the MappingName to the view (in this case) and click the
GridColumnStyle s
(Colloection) field and the ... button.

Now add as many columns that you need to show in the grid.

Give them unique names and HeaderText titles. Set the MappingName and
the width.

Click OK, OK and run the application.

And all I did was reading the help file a little and Voila!

Happy programming.


Dec 7 '05 #3

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

Similar topics

by: David Tilman | last post by:
I have an ASP .NET web application that changes datagrid cells in the ItemDataBound event, like changing the Columnspan of a cell to 2 and deleting the adjacent cell, so that I have two cells merged into one. I was wanting to do something similar in another part of the program (right after the DataBind() for the datagrid). Where I could select...
by: ASzasz | last post by:
I am new to VB .NET: I can configure a SQL adapter and access data via the datagrid. But how do you access and manipulate data if you do not require the data to show up on a form. I simply want to audit a SQL table's data using code to cycle through all records. The user doesn' t need to see the table data. Any help appreciated.
by: Daniel Kaseman | last post by:
What's the best way to manipulate a Microsoft Access Database from VB .Net? I have gotten as far as making and configuring a OleDbAdapter, connection, and Dataset, which is bound to a data grid. I'm able to see the data in the table on the data grid when my VB program is running, and I can type new data in, but I don't know how to actually...
by: fripper | last post by:
I am at my wits end trying to do a very simple task in VB .Net. I have spent a number of hours trying to figure out how to use datasets, datatables and the Datagrid control but I am lost in the mass of functionality and details that these entail. My task is simple ... I simply want to display a bunch of data (not from an SQL darabase) in...
by: Maarten | last post by:
Hi all, I have a datagrid with questions where the user has to make a choice (yes or no questions) But for some questions there are rules, like if you choose (yes or no) for some questions I need to skip 1 or more questions. e.g. Q1. Do you..... Y | N Q2. Do you..... Y | N
by: Maarten | last post by:
Hi all, I have a datagrid (GridView) with questions where the user has to make a choice (yes or no questions) But for some questions there are rules, like if you choose (yes or no) for some questions I need to skip 1 or more questions. e.g. Q1. Do you..... Y | N
by: michael sorens | last post by:
I have been trying to figure out how to use DataSets, BindingSources, DataGridViews, and XML together, but it is a challenge. I understand how to populate a DataGridView with XML basically as: DataSet ds = new DataSet(); ds.ReadXml(@"\usr\tmp\sample.xml"); dataGridView.DataSource = ds; dataGridView.DataMember = "targetElement"; What I...
by: paulinus | last post by:
i am currently developing an application using vb 6.0 and ms access as database. the following problems are delaying its submission: 1. there are three (3) records in the datagrid, but only the first gives a positive result "found" when 'searched for' by , despite the fact that there are three of them which gives negative result "not...
by: ssknov | last post by:
hi all I have a grid. when a the grids cell value is clicked its whole datas (other remaining fields of that record)should be displayed in textboxes. I had already populated the datagrid with dataset. giv me tip how to do this Thanks in advance.
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
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...
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...
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...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.