Results 1 to 2 of 2

Thread: Best way to keep track of user added datagridview headers?

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2013
    Posts
    42

    Best way to keep track of user added datagridview headers?

    I'm building a tool that will easily create a CSV for use with a online store product importer.

    I want to create a form where a user can input data into text fields and then use that information to add a row to a datagridview. Once all the products are added, the application will export the DGV to a CSV file.

    I am having trouble thinking of a way for the headers to work for the DGV. Along side many preset columns and corresponding text boxes I want the user to be able to create their own columns and form text fields when adding their information in. This will allow the application to be compatible with exporting custom import fields.

    I have been brainstorming for days now and can't think of a clean solution. One thing I thought of doing is leaving blank text boxes on the form for the user to fill in for their custom settings. when clicking add product I can't think of a way to add the corresponding text box value with the newly added header.

    I've made a couple applications in the past but not much experience using datagridviews. I am open to ideas. I thought the datagridview would be nice to show a preview of the file before exporting it.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Best way to keep track of user added datagridview headers?

    All you need to do is store the column names in a List(Of String). You can then loop through that list and add a TextBox for each one, probably with an accompanying Label for the column name, and also add a column to the grid for each one. With regards to the TextBoxes, you'd probably want to use a TableLayoutPanel or FlowLayoutPanel as a container so that you can simply add a new control and the layout will be handled automatically. If you do need a Label with each TextBox then I'd suggest a user control to contain both.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width