none
Populate Datagridviwe starting at the second column RRS feed

  • Question

  • Hi guys i am a total newbie so....

    I'm populating a data grid with information i parsed from a website.

    I have 3 Columns in my data grid.

    Row Number
    Name
    Score

    Currently name is being populated into the RowNumber column.

    How do i change it ?

    Thanks

    Monday, October 14, 2019 2:56 AM

All replies

  • Hi De Bil,

    I'm not sure if I can understand your situation.

    Firstly, remember row number and column number in DataGridView begins from zero.Secondly, try to paste data from a website into Excel sheet or text editor and check how the data is populated.
    (I guess Row Number does not exist in the parsed data.)

    I hope you will provide your code.

    Regards,

    Ashidacchi -- http://hokusosha.com

    • Edited by Ashidacchi Monday, October 14, 2019 3:19 AM
    Monday, October 14, 2019 3:16 AM
  • so my question is basically how do i start populating the datagrid from row{0} and Column{1} ?



    • Edited by De Bil Monday, October 14, 2019 3:02 PM
    Monday, October 14, 2019 3:02 PM
  • so my question is basically how do i start populating the datagrid from row{0} and Column{1} ?



    It depends on how data is being loaded into the DataGridView

    • Cell by cell
    • Setting the DataSource

    If the columns are done in the DataGridView designer make sure the DataPropertyName is correct.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, October 14, 2019 7:32 PM
    Moderator
  • Hi De Bil

    Thank you for posting here.

    >>how do i start populating the datagrid from row{0} and Column{1} ?

    First, you could convert current datagridview to datatable. Then, please remove the first column.

    The following code has done it.

     private void button1_Click(object sender, EventArgs e)
            {
                DataTable dt = (DataTable)dataGridView1.DataSource;
                dt.Columns.RemoveAt(0);
    
    
            }

    Result:

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, October 15, 2019 5:21 AM
    Moderator