Hello,
Im creating a TS3 server admin tool. And Im having a Problem adding items to the DAtagrid View.

Ive got like 8 Columns and I want to add this data to the correct Column But IDK What Im Doing Wrong

  • #
  • Server ID
  • Server Port
  • Server Status
  • Clients
  • Slots
  • Server Name
Dim ServerList As ListResponse(Of ServerListItem) = queryRunner.GetServerList(includeAll:=True)
                        ' If Their Is An Error With The Server Listing
                        If ServerList.IsErroneous Then
                            ' Then, Display A MessageBox With The Error Number And The Error Message Associated To This Number
                            MessageBox.Show((ServerList.ErrorId + " : " + ServerList.ErrorMessage & vbCr & vbLf) + ServerList.ResponseText)
                        Else
                            For Each item As ServerListItem In ServerList

                                DataGridView1.Rows.Add(item.ServerMachineId)
                                DataGridView1.Rows.Add(item.ServerId)
                                DataGridView1.Rows.Add(item.ServerPort)
                                DataGridView1.Rows.Add(item.ServerStatus)
                                DataGridView1.Rows.Add(item.ServerNumberOfClientsOnline)
                                DataGridView1.Rows.Add(item.ServerMaximumClientsAllowed)
                                DataGridView1.Rows.Add(item.ServerName)

                                queryRunner.SelectVirtualServerById(item.ServerId)
                                ' Get The Server Infos Of The Current Selected Server In The List
                                ' And Put The Result In ServerInfos Object Of "ServerInfoResponse Type
                                Dim ServerInfos As ServerInfoResponse = queryRunner.GetServerInfo()
                                ' If Their Is An Error While Getting The Server Infos
                                If ServerInfos.IsErroneous Then
                                    ' Show A Message Error With Error Id And Error Message
                                    MessageBox.Show((("Error While Getting Server Infos !" & vbCr & vbLf + ServerInfos.ErrorId & " : ") + ServerInfos.ErrorMessage & vbCr & vbLf) + ServerInfos.ResponseText)
                                Else

                                    btnDisconnect.Enabled = True
                                    btnConnect.Enabled = False
                                End If
                            Next
                        End If

I'd Love some help. Thanks In Advance! :)

Im Not Getting an Error. Its not Displaying any Data At all. When I use one like this

DataGridView1.Rows.Add(item.ServerName)

It Displays the Data in the First Column.

Here is an Example of What is happening with pics

http://www.globalvirtualairlines.com/c/Image5.png
With This Code:

Dim ServerList As ListResponse(Of ServerListItem) = queryRunner.GetServerList(includeAll:=True)
                        ' If Their Is An Error With The Server Listing
                        If ServerList.IsErroneous Then
                            ' Then, Display A MessageBox With The Error Number And The Error Message Associated To This Number
                            MessageBox.Show((ServerList.ErrorId + " : " + ServerList.ErrorMessage & vbCr & vbLf) + ServerList.ResponseText)
                        Else
                            For Each item As ServerListItem In ServerList

                                DataGridView1.Rows.Add(item.ServerName)

                                queryRunner.SelectVirtualServerById(item.ServerId)
                                ' Get The Server Infos Of The Current Selected Server In The List
                                ' And Put The Result In ServerInfos Object Of "ServerInfoResponse Type
                                Dim ServerInfos As ServerInfoResponse = queryRunner.GetServerInfo()
                                ' If Their Is An Error While Getting The Server Infos
                                If ServerInfos.IsErroneous Then
                                    ' Show A Message Error With Error Id And Error Message
                                    MessageBox.Show((("Error While Getting Server Infos !" & vbCr & vbLf + ServerInfos.ErrorId & " : ") + ServerInfos.ErrorMessage & vbCr & vbLf) + ServerInfos.ResponseText)
                                Else

                                    btnDisconnect.Enabled = True
                                    btnConnect.Enabled = False
                                End If
                            Next
                        End If

http://www.globalvirtualairlines.com/c/55555.png
With This Code:

Dim ServerList As ListResponse(Of ServerListItem) = queryRunner.GetServerList(includeAll:=True)
                        ' If Their Is An Error With The Server Listing
                        If ServerList.IsErroneous Then
                            ' Then, Display A MessageBox With The Error Number And The Error Message Associated To This Number
                            MessageBox.Show((ServerList.ErrorId + " : " + ServerList.ErrorMessage & vbCr & vbLf) + ServerList.ResponseText)
                        Else
                            For Each item As ServerListItem In ServerList

                                DataGridView1.Rows.Add(item.ServerMachineId)
                                DataGridView1.Rows.Add(item.ServerId)
                                DataGridView1.Rows.Add(item.ServerPort)
                                DataGridView1.Rows.Add(item.ServerStatus)
                                DataGridView1.Rows.Add(item.ServerNumberOfClientsOnline)
                                DataGridView1.Rows.Add(item.ServerMaximumClientsAllowed)
                                DataGridView1.Rows.Add(item.ServerName)

                                queryRunner.SelectVirtualServerById(item.ServerId)
                                ' Get The Server Infos Of The Current Selected Server In The List
                                ' And Put The Result In ServerInfos Object Of "ServerInfoResponse Type
                                Dim ServerInfos As ServerInfoResponse = queryRunner.GetServerInfo()
                                ' If Their Is An Error While Getting The Server Infos
                                If ServerInfos.IsErroneous Then
                                    ' Show A Message Error With Error Id And Error Message
                                    MessageBox.Show((("Error While Getting Server Infos !" & vbCr & vbLf + ServerInfos.ErrorId & " : ") + ServerInfos.ErrorMessage & vbCr & vbLf) + ServerInfos.ResponseText)
                                Else

                                    btnDisconnect.Enabled = True
                                    btnConnect.Enabled = False
                                End If
                            Next
                        End If

have you added Columns in Datagridview programatically or using designer?

well, one suggestion is this:

change you code

DataGridView1.Rows.Add(item.ServerMachineId)
                                DataGridView1.Rows.Add(item.ServerId)
                                DataGridView1.Rows.Add(item.ServerPort)
                                DataGridView1.Rows.Add(item.ServerStatus)
                                DataGridView1.Rows.Add(item.ServerNumberOfClientsOnline)
                                DataGridView1.Rows.Add(item.ServerMaximumClientsAllowed)
                                DataGridView1.Rows.Add(item.ServerName)

to

DataGridView1.Rows.Add(item.ServerMachineId,item.ServerId,item.ServerPort,item.ServerStatus,item.ServerNumberOfClientsOnline,item.ServerMaximumClientsAllowed,item.ServerName)

i think it should work..

your datagridview row contains the columns like machineid,serverid etc.. this are not rows..

Hahahhaahaha. OMG that worked. Thanks
Now Another Question.
Is there a way to get rid of that Thing with the Arrow on it?

The Very left Column thats really tiny.

Edited 5 Years Ago by Joshua Kidd: n/a

it is possible..

set

Datagridview1.RowHeadersWidth = 10;

set it to any small number that suits you (but its minimum size is 4.)

Edited 5 Years Ago by sandeepparekh9: n/a

Thanks. I found a Row Header Visible. That worked too.
Thanks for the help guys. :)

This question has already been answered. Start a new discussion instead.