datagrid view real NOOB

Hi i never used the datagrid. As i see in this forum and others the datagrind has most questions
but il put a simple one

How to fill a column from a datagrid view

Hope is easy, and i would apriciate a good tutorial (BTW forgive my english)

Thanks!!



Answer this question

datagrid view real NOOB

  • JAgiato

    Ok how do i refresh the datagrid view
    And a few days ago i saw a program that had a progress bar in the datagrid. How did he made that


  • Alain Dupont

    Shakalma is almost right. To access any row or column in a datagridview you simply using the following:

    dgv.Rows[0]["Name"].Value = "Name Value";

    To access the column you can use either the Name you assigned it or the column index value so it could also be

    dgv.Rows[0][0].Value = "Name Value";

    Also just to let you know, lets say in the case that you use a dataview or you have bound a table to the datagridview. Then you could also just access the dataview or datatable and refresh the grid. For those object's accessing a particiular cell would be just the same as before except you do not use a .Value to assign the data.

    dv.Rows[0]["CellName"] = "Cell Value";



  • Pedro Querido

    hi,

    yes you get the datagridview cells by its coordinates

    this.DataGridView.Rows[0].Cells[0].Value = "something";

    but it will be better if you bind your datagridview to table using bindingsource that will be much comfort for you and every thing will be done for you , you don't have to get cells one by one to add or edit data , as soon as you make chanages in the datagrid it will be done in your dataset when you finish editing or adding you can update your source just once

    hope this helps



  • netdev09

    i`m not sure even myself what i what to do, coz` as i said i know NOTHING about datagrid view, only that is nice table.. :D

    i think your reply is my answer!!

    More specific :
    How to fill the first row from datagrid
    My datagrid looks like this:
    ------------------------------------------------------
    | Name | Size | Path | Information |
    ------------------------------------------------------
    | | | | |
    ------------------------------------------------------

    how do i fill the Name Size Path and information with soem data:

    I was hopeing is like this

    DataGridView.Row1.Column1.Text="dsaasdas" ; :DDDD

    do i really have to make a table


  • ajakeman

    Im not sure what your question is exactly. Are you wanting to know how to fill a datagrid or a datagridview More or less both are very similiar so i hope this helps.

    First you must fill a DataTable with the information of what you have. I will programmitically create a table, put some data in there and bind it to a datagrid, hoping that this will give your your answer.

    // Create Table
    System.Data.DataTable dt = new System.Data.DataTable();

    // Add Columns to Table
    dt.Columns.Add("Name");
    dt.Columns.Add(
    "Phone");
    dt.Columns.Add(
    "Age");

    // Add a Few Rows to Table
    System.Data.DataRow row1 = dt.NewRow();
    row1[
    "Name"] = "Wonder Women";
    row1[
    "Phone"] = "555-555-5555";
    row1[
    "Age"] = "29";
    dt.Rows.Add(row1);

    System.Data.DataRow row2 = dt.NewRow();
    row2[
    "Name"] = "Captain America ";
    row2[
    "Phone"] = "555-555-5555";
    row2[
    "Age"] = "32";
    dt.Rows.Add(row2);

    // Now that we have a loaded DataTable all we have to do is apply it to our DataGrid
    DataGridName.DataSource = dt;

    And there you have it. Your DataGrid should now be populated with the information in your DataTable. I hope this helps... If it does not be a little more specific in your question and ill do my best to help you out.



  • _martin_

    Well to resfresh the datagridview is quite easy. All you do is type:

    dgvname.Refresh();

    Now as far as the progressbar goes it's quite simple as well, but it all depends on what you want the progressbar to show... Updates, Deletions, or Pulling in data into the grid and if updates how you are updating your info.

    But basically there are events placed inside of the datagridview such as the RowsAdded event or the RowsRemoved Event which you could take advantage of. Or on the datatable there is the RowChanged and RowDeleted event. Of course you can also always itterate through the event of updates or what not per item on the datatable and display a progress bar for this, but it is slower....



  • datagrid view real NOOB