Link to home
Start Free TrialLog in
Avatar of LeighWardle
LeighWardleFlag for Australia

asked on

Visual Studio 2013 - How can I determine what database is being used by a Data Grid View (dgv) control in run time?

Hi Experts,

I am trying to debug my vb.net program.

How can I determine what database is being used by a Data Grid View (dgv) control in run time?

My Data Grid View (dgv) control is dgvMaterials.

When my form is loaded and I check the values of dgvMaterials in the Immediate window using ?dgvMaterials, I get this output:

?dgvMaterials
{System.Windows.Forms.DataGridView}
    AccessibilityObject: {ControlAccessibleObject: Owner = System.Windows.Forms.DataGridView}
    AccessibleDefaultActionDescription: Nothing
    AccessibleDescription: Nothing
    AccessibleName: Nothing
    AccessibleRole: Default {-1}
    AdjustedTopLeftHeaderBorderStyle: {DataGridViewAdvancedBorderStyle { All=NotSet, Left=OutsetDouble, Right=Outset, Top=OutsetDouble, Bottom=Outset }}
    AdvancedCellBorderStyle: {DataGridViewAdvancedBorderStyle { All=Single, Left=Single, Right=Single, Top=Single, Bottom=Single }}
    AdvancedColumnHeadersBorderStyle: {DataGridViewAdvancedBorderStyle { All=OutsetPartial, Left=OutsetPartial, Right=OutsetPartial, Top=OutsetPartial, Bottom=OutsetPartial }}
    AdvancedRowHeadersBorderStyle: {DataGridViewAdvancedBorderStyle { All=OutsetPartial, Left=OutsetPartial, Right=OutsetPartial, Top=OutsetPartial, Bottom=OutsetPartial }}
    AllowDrop: False
    AllowUserToAddRows: False
    AllowUserToAddRowsInternal: False
    AllowUserToDeleteRows: False
    AllowUserToDeleteRowsInternal: False
    AllowUserToOrderColumns: False
    AllowUserToResizeColumns: True
    AllowUserToResizeRows: True
    AlternatingRowsDefaultCellStyle: {DataGridViewCellStyle { }}
    Anchor: Top Or Left {5}
    ApplyVisualStylesToHeaderCells: False
    ApplyVisualStylesToInnerCells: False
    AutoGenerateColumns: False
    AutoScrollOffset: {X = 0 Y = 0}
    AutoSize: False
    AutoSizeColumnsMode: None {1}
    AutoSizeRowsMode: AllCells {7}
    BackColor: "{Name=Control, ARGB=(255, 240, 240, 240)}"
    BackColorBrush: 1048738
    BackgroundBrush: {Color = {Color [AppWorkspace]}}
    BackgroundColor: "{Name=AppWorkspace, ARGB=(255, 171, 171, 171)}"
    BackgroundImage: Nothing
    BackgroundImageLayout: Tile {1}
    BecomingActiveControl: False
    BindingContext: {System.Windows.Forms.BindingContext}
    BindingContextInternal: {System.Windows.Forms.BindingContext}
    BorderStyle: FixedSingle {1}
    Bottom: 322
    Bounds: {X = 0 Y = 0 Width = 664 Height = 322}
    BufferPinkRect: Nothing
    CachedImeMode: NoControl {0}
    CacheTextInternal: False
    CanAccessProperties: True
    CanEnableIme: False
    CanFocus: True
    CanRaiseEvents: True
    CanRaiseEventsInternal: True
    CanSelect: True
    Capture: False
    CaptureInternal: False
    CausesValidation: True
    CellBorderStyle: Single {1}
    CellMouseDownInContentBounds: False
    CellPaintingEventArgs: {System.Windows.Forms.DataGridViewCellPaintingEventArgs}
    CellValueEventArgs: {System.Windows.Forms.DataGridViewCellValueEventArgs}
    CheckForIllegalCrossThreadCalls: False
    ClientRectangle: {X = 0 Y = 0 Width = 664 Height = 322}
    ClientSize: {Width = 664 Height = 322}
    ClipboardCopyMode: EnableWithAutoHeaderText {1}
    ColumnCount: 17
    ColumnHeadersBorderStyle: Raised {2}
    ColumnHeadersDefaultCellStyle: {DataGridViewCellStyle { BackColor=Color [Control], ForeColor=Color [WindowText], SelectionBackColor=Color [Highlight], SelectionForeColor=Color [HighlightText], Font=[Font: Name=Microsoft Sans Serif, Size=8.25, Units=3, GdiCharSet=0, GdiVerticalFont=False], WrapMode=True, Alignment=MiddleLeft }}
    ColumnHeadersHeight: 47
    ColumnHeadersHeightSizeMode: DisableResizing {1}
    ColumnHeadersVisible: True
    Columns: {System.Windows.Forms.DataGridViewColumnCollection}
    CompanyName: "Microsoft Corporation"
    Container: Nothing
    ContainsFocus: False
    ContextMenu: Nothing
    ContextMenuStrip: Nothing
    ControlKeyboardRouting: Nothing
    Controls: {System.Windows.Forms.DataGridView.DataGridViewControlCollection}
    Created: True
    CreateParams: {CreateParams {'', '', 0x56010000, 0x0, {0, 0, 664, 322}}}
    CreateThreadId: 3024
    CurrentCell: {DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=0 }}
    CurrentCellAddress: {X = 0 Y = 0}
    currentHelpInfo: Nothing
    CurrentImeContextMode: Inherit {-1}
    CurrentRow: {DataGridViewRow { Index=0 }}
    Cursor: {[Cursor: Default]}
    CursorInternal: Write Only Properties are not supported
    DataBindings: {System.Windows.Forms.ControlBindingsCollection}
    DataConnection: {System.Windows.Forms.DataGridView.DataGridViewDataConnection}
    DataMember: ""
    DataSource: { [System.Windows.Forms.BindingSource]}
    DefaultBackColor: "{Name=Control, ARGB=(255, 240, 240, 240)}"
    DefaultCellStyle: {DataGridViewCellStyle { BackColor=Color [Window], ForeColor=Color [ControlText], SelectionBackColor=Color [Highlight], SelectionForeColor=Color [HighlightText], Font=[Font: Name=Microsoft Sans Serif, Size=8.25, Units=3, GdiCharSet=0, GdiVerticalFont=False], WrapMode=True, Alignment=MiddleLeft }}
    DefaultCursor: {[Cursor: Default]}
    DefaultFont: {Name = Reference to a non-shared member requires an object reference. Size=8.25}
    DefaultForeColor: "{Name=ControlText, ARGB=(255, 0, 0, 0)}"
    DefaultImeMode: Inherit {-1}
    DefaultMargin: {Left=3,Top=3,Right=3,Bottom=3}
    DefaultMaximumSize: {Width = 0 Height = 0}
    DefaultMinimumSize: {Width = 0 Height = 0}
    DefaultPadding: {Left=0,Top=0,Right=0,Bottom=0}
    DefaultSize: {Width = 240 Height = 150}
    DesignMode: False
    DeviceDpi: 96
    deviceDpi: 96
    < More... (The first 100 of 303 items were displayed.) >

Open in new window


I think what I am looking for is:  DataSource

But all I get is:

    DataSource: { [System.Windows.Forms.BindingSource]}

How can I determine the full path of the DataSource?

Regards,
Leigh
Avatar of LeighWardle
LeighWardle
Flag of Australia image

ASKER

I think DataSource is:

CIRCLY7.LAYERSDataSet

CIRCLY7 is the name of my .exe file.

LAYERSDataSet is a DataSet.

I've looked at all the properties of LAYERSDataSet, but none show the path to the database.
SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of louisfr
louisfr

How do you fill the dataset?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, Elron and Andy, for clear explanations.

Regards,
Leigh