Results 1 to 9 of 9

Thread: DataGridView / Data Source (Adding new row programmatically) + Custom Control 'settin

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    DataGridView / Data Source (Adding new row programmatically) + Custom Control 'settin

    This is a 2 part thread, and any help would be most welcome.


    1. I have a DataGridView box, that is connected to a MySQL database via the 'Data Source'. I am trying to do the datagridview1.rows.add("info here"), however i receive an error i cannot do this programmatically. I DO know the code to post to MySQL via the "insert into" la la la. However, I was curious if I can do this via the datagridview a bit..easier/simpler, such as a "datagridview1.rows.add(stuff)" sorta thing.




    2. I am attempting to make a custom control, and as with ANY control, they have their.. settings. Example, a textbox, or label, has so you can set the Text. and color, etc.

    Others, have it (such as datagridview) have the little icon on the control itself, where you click it, and it opens a small window with settings.


    How would I do either of those for a setting of my control?

    Thanks!

  2. #2
    Member cyberM's Avatar
    Join Date
    Mar 2009
    Location
    Croatia , Zagreb
    Posts
    61

    Re: DataGridView / Data Source (Adding new row programmatically) + Custom Control 'se

    2.)
    Private WithEvents Button as CommandButton

    Private sub Form_Load()
    Set Button=Form1.Controls.Add("VB.CommandButton","Dynamic")
    Button.Visible=True
    Button.Caption="Dynamic"
    End Sub

    Is that help ?
    If you satisfied add to reputation





    PhotoResizer GDI+Shape form,shape inside

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: DataGridView / Data Source (Adding new row programmatically) + Custom Control 'se

    Quote Originally Posted by cyberM View Post
    2.)
    Private WithEvents Button as CommandButton

    Private sub Form_Load()
    Set Button=Form1.Controls.Add("VB.CommandButton","Dynamic")
    Button.Visible=True
    Button.Caption="Dynamic"
    End Sub

    Is that help ?
    I will try it, thanks in advance though.

  4. #4
    Hyperactive Member
    Join Date
    Jun 2009
    Posts
    307

    Re: DataGridView / Data Source (Adding new row programmatically) + Custom Control 'se

    I haven't used MySQL, but when you bind a DataGridView to a DataSource, rows in the DataGridView are automatically added when you add rows to your DataSource. I'm not sure why you would want to manually add rows to just the DataGridView.
    Last edited by dkahn; Jul 30th, 2010 at 05:44 PM.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: DataGridView / Data Source (Adding new row programmatically) + Custom Control 'se

    Quote Originally Posted by dkahn View Post
    I haven't used MySQL, but when you bind a DataGridView to a DataSource, rows in the DataGridView are automatically added when you add rows to your DataSource. I'm not sure why you would want to manually add rows to just the DataGridView.
    I'm looking to add rows to the database.

    I am under the assumption that, since the datagridview1 is data bound to a database, when you add to 1, it updates the other.

  6. #6
    Hyperactive Member
    Join Date
    Jun 2009
    Posts
    307

    Smile Re: DataGridView / Data Source (Adding new row programmatically) + Custom Control 'se

    I am under the assumption that, since the datagridview1 is data bound to a database, when you add to 1, it updates the other.
    I'm almost positive that it doesn't work like that. Maybe someone else will way in and be the deciding vote.
    Last edited by dkahn; Jul 30th, 2010 at 07:34 PM.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: DataGridView / Data Source (Adding new row programmatically) + Custom Control 'se

    I fixed solution #1.

    Now, onto Problem 2. CyberM, unfortunately, that is not what I want.

    I am needing to save a variable, or a setting for a CONTROL that I am making. Not on a form.

    Thanks

  8. #8
    Hyperactive Member
    Join Date
    Jun 2009
    Posts
    307

    Re: DataGridView / Data Source (Adding new row programmatically) + Custom Control 'se

    How'd you fix solution #1?

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: DataGridView / Data Source (Adding new row programmatically) + Custom Control 'se

    Code:
    KeyTableAdapter.Fill(RegestrationDataSet.key)

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