In form1:

Sub loadData()
    Line of code loading data in gridcontrol
End sub

In form2:
Button 1 Code

Dim form1 as new form1
    form1.loadData()

This code is not working. can anyone help me?

make the sub public

Thank you but my gridcontrol is not refreshing after inserting new data.

Sub loadData()
     ConnectionStringINI = String.Format("Data Source={0};User ID={1};ServerType=LOCAL;TrimTrailingSpaces=True", DataSources, DataUsername)
    Me.ContactsGridTableAdapter.Connection.ConnectionString = ConnectionStringINI

    GridControl1.DataSource = Nothing
    GridControl1.DataSource = ContactsGridBindingSource
    Me.ContactsGridTableAdapter.Fill(Me.DataSet5.ContactsGrid)
    GridView1.Columns(1).SortOrder = DevExpress.Data.ColumnSortOrder.Ascending
End sub

Help please...

You still haven't made the sub public.

Same result.

insert a breakpoint in the first statement of the sub and go line by line and check the value of each object and variable in each statement to see if it's giving the results you want.

try to put this on your code:

   GridView1.Refresh()

another thing.. What is the true DataGrid? GridView1 or GridControl1?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.