SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Non-Member shivanee's Avatar
    Join Date
    May 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    setting column width of datagrid in vb.net winforms

    Hello all,

    The following is my join query through which I am showing the 3 columns in the datagrid as QuesGroup, Question and Answer. I want to set the column width and headertext in the datagrid at the runtime using vb.net winforms.

    I ahave used :

    dgUserResponse.PreferredColumnWidth property,but it sets the same width to all columns.

    I have used the datagridcolumnStyle property.I have searched for that also but I got only for the simple query and not for the join query.

    dgUserRsponse is my datagrid.

    Can anybody please help me out ?


    getUserResponse = "select g.QuesGroup,q.Question,u.Answer from Question q,UserResponse u,QuesGroup g where q.QuesId=u.QuesId and q.QuesGrpId=g.QuesGrpId and u.CandidateId=" & UserId & " order by u.ResId"

    cmdGetUserResponse = New OleDbCommand(getUserResponse, con)
    'drGetUserResponse = cmdGetUserResponse.ExecuteReader
    daGetUserResponse = New OleDbDataAdapter(cmdGetUserResponse)
    daGetUserResponse.Fill(dsGetUserResponse) dgUserResponse.DataSource=dsGetUserResponse.Tables(0).DefaultView

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dgUserResponse.Columns[0].Width

    I'm sure its the above.


  3. #3
    Non-Member shivanee's Avatar
    Join Date
    May 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello,

    I have tried this statement also,but it doesnt support i.e it doesn't show the column property of datagrid.I want to implement this in vb.net winforms 2003


    Any other suggestion or how can I write the statement you have suggested.

    Thanks in advance.

  4. #4
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you not have access to a Columns Property within the designer properties? You should be able to add/remove and edit columns, and the width property (at least it is in c#) can be changed.


  5. #5
    Non-Member shivanee's Avatar
    Join Date
    May 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello,

    No there in no "columns" property in vb.net winforms .The "columns" property is in the Asp.Net web application and doing it in the vb.net winforms 2003.

    So, any other solution is there to set the width property of the datagrid?

    Thanks in advance.

  6. #6
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry I don't really use VB.Net, I only use C# which does have a Columns property IIRC.

    After a quick search I found:

    http://support.microsoft.com/kb/811203

    with :

    Code:
    DataGrid1.TableStyles("Employees").GridColumnStyles("Title").Width = newwidth



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •