DataGridComboboxColumn-VBForums
Results 1 to 6 of 6

Thread: DataGridComboboxColumn

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    UAE
    Posts
    191

    DataGridComboboxColumn

    Hiii all.
    I have used datagridview in my form show all data and to enter by it.
    Now I have a field which is type field which needs only 1 of 7 types. i.e.
    1.Type AA
    2. Type BB
    3.Type CC
    ...
    7 _____


    So I want to put combobox in datagrid. How can i asign a combo to my database field in grid.???????

    Thank you in advance
    Each New Difficulty Is Best Opportunity,
    If You Ignore Solving It,
    You Lost Your Life's Best Opportunity.
    _______________________________________
    Dynamic Property value assignment - C#
    TCP client/server connection

    CatchIt-Game
    Fortunes
    SQL Tutorials

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,817

    Re: DataGridComboboxColumn

    Hi,

    If you right click the grid at design time and select Edit Columns, the Column Editor will appear. Select the column that you want to have appear as a combobox and change the ColumnType property to DataGridViewComboBoxColumn.

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    UAE
    Posts
    191

    Re: DataGridComboboxColumn

    yes u r right, but i want to asign columns at runtime. I dont asign columns invdividually but it takes them from table structure.
    After asigning datasource I want to make column(1) a comboboxcolumn.
    Each New Difficulty Is Best Opportunity,
    If You Ignore Solving It,
    You Lost Your Life's Best Opportunity.
    _______________________________________
    Dynamic Property value assignment - C#
    TCP client/server connection

    CatchIt-Game
    Fortunes
    SQL Tutorials

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,109

    Re: DataGridComboboxColumn

    You cannot change the type of an existing column at run time. If you don't want to accept the default column type created by the grid then you need to create the column yourself. You can do it in code but you wouldn't. You would do it in the designer as sparrow1 says. You need to set the column's DataPropertyName property to the name of the DataColumn you want it bound to. That way, that column in the DataTable will be bound to your combo box column instead of the grid creating a new one.

    By the way, I ignored this thread the first time I saw it because the title said "DataGridComboBoxColumn". If it had said "DataGridViewComboBoxColumn" like it should I would have answered then and you would have got your solution sooner. Names are important. Use the right ones and people will know exactly what you're yalking about.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    UAE
    Posts
    191

    Re: DataGridComboboxColumn

    ok. So what can I do for it? Can I put validation on this field? If not is there any other control to do so? Can we do it by listview?

    If there's not a single positive answer I will have to change concept of my entry form.
    Thank you for a cooperation.
    Each New Difficulty Is Best Opportunity,
    If You Ignore Solving It,
    You Lost Your Life's Best Opportunity.
    _______________________________________
    Dynamic Property value assignment - C#
    TCP client/server connection

    CatchIt-Game
    Fortunes
    SQL Tutorials

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,109

    Re: DataGridComboboxColumn

    Once you've added the column you can treat it like a ComboBox, so you can add your valid values to its Items collection or you can bind a list to it via its DataSource, just as you would with a regular ComboBox.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.