Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DataSet to fit DataGrid

Posted on 2006-07-19
7
Medium Priority
?
337 Views
Last Modified: 2008-03-06
Hi,

I load a dataset into a datagrid from XML file. The file loads correctly but its display doesn't completely fit the datagrid: there is a grey space on the right. I want to get rid of that grey space so that the data columns are expanded to use all of the space available. The first column, where you select the rows, shouldn't be expanded. How do I achieve this? I looked into DataGridTableStyle class but I couldn't figure out how to use it; it seems to repeat the same methods from DataGrid class. Thanks for your help.

 Private Sub Form1_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load
        LoadXMLData()
    End Sub    

    Private Sub LoadXMLData()
        ds = New DataSet
        ds.ReadXml("c:\rules.xml")
        xmlRules.SetDataBinding(ds, "rule")
        tbl = ds.Tables(0)
    End Sub

XML file example
========

<?xml version="1.0"?>
<folder-rules>
  <rule>
    <variable>m_EDSTYPCD</variable>
    <value>P</value>
    <destination>Facilities</destination>
    <default>Blah</default>
    <function>PrintGreeting</function>
    <param1>Hello</param1>
    <param2>World</param2>
    <level>1</level>
  </rule>
</folder-rules>
0
Comment
Question by:njava
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 1

Author Comment

by:njava
ID: 17140604
xmlRules is a DataGrid
ds is a DataSet
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17141403
1) Define a DataGridTableStyle
2) Specify each column type as DataGridTextBoxColumn, DataGridBoolColumn, etc.
3) Define the column widths as a percent of ClientSize.Width for the entire DataGrid.

Bob
0
 
LVL 1

Author Comment

by:njava
ID: 17141651
Would it be possible to provide an example?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 200 total points
ID: 17141708
Example:

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21876101.html

Set column widths like this:

Column 1:  DataGrid1.ClientSize.Width * .25
Column 2:  DataGrid1.ClientSize.Width * .25
Column 3:  DataGrid1.ClientSize.Width * .25
Column 4:  DataGrid1.ClientSize.Width * .10
Column 5:  DataGrid1.ClientSize.Width * .5
Column 6:  DataGrid1.ClientSize.Width * .20

The total needs to be 1.00 or 100% of the width.

Bob
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question