How to use DataGridView Control in C#

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 พ.ค. 2019
  • This short video shows how you can populate and use DataGridView Control in C#.
    In this video you get to learn how to:
    - populate the data in the DataGridView
    - how to configure DataGridView Control to allow FullRowSelect -
    - how to retrieve dhe DataBoundItem from the selection of the row.
    I hope you enjoy it.
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 69

  • @fallingman8470
    @fallingman8470 2 ปีที่แล้ว +14

    That cursor is so visible! I had no trouble locating the cursor during this video. 10/10

  • @user-ts9rr5bp9h
    @user-ts9rr5bp9h 4 ปีที่แล้ว +5

    This is really really helpful ! !

  • @LordDungeon
    @LordDungeon ปีที่แล้ว

    Omg this is exactly what I need. I have absolutely no knowledge on how to use visual studio. Thank you very much. Have a nice day :)

  • @christopherlikins6321
    @christopherlikins6321 2 ปีที่แล้ว +3

    Thank you for this instruction. It is very clear and well stepped through on the procedure.

  • @dineshodedra4460
    @dineshodedra4460 3 ปีที่แล้ว +2

    Great video. I'm new to C# but have lots of "lapsed" coding experience. I loved the way you created the class objects and the list to use with the grid. These tutorials are for beginners so it was perfect. I have seen so many othe tutorials that make the guy on the video sound clever but they struggle to get the main objective across.
    For completness, you could have updated the data in one of the cells with the text you edited.
    Great work, keep it up

    • @ProgrammersNerds
      @ProgrammersNerds  3 ปีที่แล้ว

      Thanks for your feedback. I try to make short vids, busy days nowadays

  • @abdelmalektalbi7582
    @abdelmalektalbi7582 4 ปีที่แล้ว +10

    I hate when my teachers take their time to explain what they're typing, explaining the obvious.
    Best tuto ever!
    one small detail ,it would have been a wonderful addition if you posted the code to...

    • @ProgrammersNerds
      @ProgrammersNerds  3 ปีที่แล้ว

      We aim to provide hands on and direct to the point tutorials.

  • @hemalpatel9708
    @hemalpatel9708 ปีที่แล้ว

    Nice tutorial, It helps me to create a view for data using data grid view, before I was creating custom UI for editing and viewing purpose, but Now I decided to use custom UI to provide basic data to user for records and use data grid view to view all data to user! Thanks a lot!

  • @ragtop63
    @ragtop63 3 ปีที่แล้ว +2

    Excellent video!
    Also, it sounds like your computer's fan curve is very aggressive lol

  • @tomd5678
    @tomd5678 4 ปีที่แล้ว +1

    Great, I learned some good stuff

  • @limtseng7157
    @limtseng7157 3 ปีที่แล้ว

    thank you, this is really helpful.

  • @JoshuaPraiz
    @JoshuaPraiz 27 วันที่ผ่านมา

    Awesome!!!

  • @jesusstudentbrett
    @jesusstudentbrett 2 ปีที่แล้ว +3

    I certainly appreciate your work and sharing this, but just a heads up; the audio is just barely loud enough (youtube max volume and my PC on max volume).

    • @ProgrammersNerds
      @ProgrammersNerds  2 ปีที่แล้ว

      Thanks, they were recorded with laptop mice so I understand you its a bit low :(

  • @williamazz2113
    @williamazz2113 2 ปีที่แล้ว

    Excellent tutorial. Great style. You covered the perfect amount of information for a complete sample solution. Thanks for sharing.

  • @ardiansanando59
    @ardiansanando59 2 ปีที่แล้ว

    thank you very much!!

  • @krastinabrunson34
    @krastinabrunson34 3 ปีที่แล้ว

    Awesome, you helped me understand dgv. Thank you. Do you logically after of course learning you figured how to set button or text box controls?

    • @ProgrammersNerds
      @ProgrammersNerds  3 ปีที่แล้ว

      Every time you update the dgv, you can set text property for example to count number of rows or so.

    • @krastinabrunson34
      @krastinabrunson34 3 ปีที่แล้ว

      @@ProgrammersNerds I did that but the Delete is not working in random order with the code. It just deletes 1st,2nd,3rd, when i try to select 5th it deletes the 1st.
      How do set it up to work at random selection of row?

    • @ProgrammersNerds
      @ProgrammersNerds  3 ปีที่แล้ว

      @@krastinabrunson34 every control in Windows Forms, has a Tag object property, you can attach your object here, like a class instance which represents your row, and then you have to get the selected row, through dataGridView1.SelectedRows[0], and then you get the object from .Tag and cast it to your object. and in the object you will have some sort of ID that represent your PrimaryKey i your Table. If you have problems, please share your code and I will be glad to help.

  • @oscaraward6187
    @oscaraward6187 3 ปีที่แล้ว +5

    Nice tutorial but how do I update the data as well as add and remove rows? I added an update, add, and remove button but I'm not sure what code to use.

    • @lshbySareena
      @lshbySareena 2 ปีที่แล้ว +1

      Add databound button
      In the button click event you can give operations code

    • @hemalpatel9708
      @hemalpatel9708 ปีที่แล้ว

      You can Add record directly to the list instead because I think Data grid view will use the list to display data, but you might have to update the data grid view

  • @vicenzovendetta3443
    @vicenzovendetta3443 2 ปีที่แล้ว

    Thank you

  • @unabletoluxury
    @unabletoluxury 3 ปีที่แล้ว

    Thank you very much

  • @antoni9001
    @antoni9001 4 ปีที่แล้ว +2

    Good movie

  • @dimankan
    @dimankan 2 ปีที่แล้ว

    i want to see more about datamember, datasource and binding

    • @ProgrammersNerds
      @ProgrammersNerds  2 ปีที่แล้ว +1

      Binding is so easy, for your reference. DataSource accepts all sorts of IList, DataMember is the value of the column from the dataSource SET, DataValue is what is returned on the click. Please, see other videos as I believe I have used it somewhere.

  • @scarr6606
    @scarr6606 ปีที่แล้ว

    At 2:36 you remove "throw new NotImplementedException();" and I receive errors when I remove it. Any suggestion's?

  • @dimankan
    @dimankan 2 ปีที่แล้ว

    спасибо

  • @sarimsheikh140
    @sarimsheikh140 หลายเดือนก่อน

    Sir how do u duplicate using drag ?????

  • @Ravenovskii
    @Ravenovskii 3 ปีที่แล้ว

    DUDE YOU ARE SO FUCKING AMAZING

  • @mejmeiji2008
    @mejmeiji2008 2 ปีที่แล้ว

    I hope there's a button to enter then view in datagridview

  • @emregecer1216
    @emregecer1216 3 ปีที่แล้ว

    Hi, i'm trying to write program which is has to connect ftp server and take , add and delete data data from server. I have no idea how to do it. i have server http address also id and pass. Can you show us how to do that if its not so hard? i watched some videos already but they have path of files, I dont have path just address of server

    • @ProgrammersNerds
      @ProgrammersNerds  3 ปีที่แล้ว

      Hi Edgar, this is what you need to do (an example):
      using (var client = new WebClient())
      {
      client.Credentials = new NetworkCredential(ftpUsername, ftpPassword);
      client.UploadFile("ftp://yourfile.txt", WebRequestMethods.Ftp.UploadFile, localFile);
      }

  • @bashayerm2412
    @bashayerm2412 2 ปีที่แล้ว

    Hi
    I have problem in passing data in grid view, if it’s possible can you help me
    Thank you

    • @ProgrammersNerds
      @ProgrammersNerds  2 ปีที่แล้ว

      Any IEnumerable, IList passed to the list.DataSource will work

  • @Laugny
    @Laugny 3 ปีที่แล้ว +1

    it says inconsisten accessability: property type 'list' is less accessible then Property 'Form1.People'

    • @Laugny
      @Laugny 3 ปีที่แล้ว +1

      i fixed it lol

    • @ProgrammersNerds
      @ProgrammersNerds  3 ปีที่แล้ว +1

      good (Y)

    • @danielruzsik6440
      @danielruzsik6440 2 ปีที่แล้ว

      @@Laugny how did you fix it?

    • @Laugny
      @Laugny 2 ปีที่แล้ว

      @@danielruzsik6440 Ohh, im sorry i dont know anymore, this project is about 3months old and i dont have a clue how i fixed it, but it wasnt that hard i think

    • @danielruzsik6440
      @danielruzsik6440 2 ปีที่แล้ว +1

      @@Laugny not a big deal, thanks anyway :D

  • @tomljenovicvid61
    @tomljenovicvid61 2 ปีที่แล้ว

    Is it even possible for me to load pictures from online database in fowlayoutpanel, then on click enter a new form with only selected object (i managed these two things) but then I want to have a button "add to cart" which is a completely separate form. The cart should be consisted solely of datagridview which collects products added to it. Right now I can only showcase each last added product. It seems they dissappear as soon as I leave the form (cart) with datagrid on it.

    • @ProgrammersNerds
      @ProgrammersNerds  ปีที่แล้ว

      Of course, usually online images or files rely on some file server to be served, and accessed via urls. Having accessed the resources and created image objects you can displat them anywhere

  • @yigitkeles3217
    @yigitkeles3217 ปีที่แล้ว

    4:53

  • @adematabag9161
    @adematabag9161 3 ปีที่แล้ว

    Could you please comment me the shortcut keys you use? You are coding very fast.

    • @ProgrammersNerds
      @ProgrammersNerds  2 ปีที่แล้ว +2

      Hello Adem, coding fast is because of my experience with coding. let me give you an example. if you want to write code like Console.WriteLine / / use write Console.WL + Tab it generates automatically. If you want to create a property on your class then write: prop + double tab, etc etc.

  • @mikaverhoeven3513
    @mikaverhoeven3513 2 หลายเดือนก่อน

    drag n drop, really man?

  • @RonTDC
    @RonTDC 3 ปีที่แล้ว

    Great video, but you type superfast lol

  • @kenwatson378
    @kenwatson378 3 ปีที่แล้ว

    Seriously? You cant build your project and class ahead of time. I know how to create a class and add items to a list. Why waste everyone's time by not setting up ahead of time so you can show us what the video was SUPPOSED to be about?

    • @FiksIIanzO
      @FiksIIanzO 3 ปีที่แล้ว +8

      Because it takes very little time and complete newbies watch these videos along with rusty professionals. The newbies would be lost without a proper step-by-step. If you're a huge dude and your time costs five bucks a second, read documentation. That's dense and quick if you know what you're doing. Otherwise check your attitude.

  • @Barbarossa-jb6cv
    @Barbarossa-jb6cv ปีที่แล้ว +1

    public partial class Form1 : Form
    {

    SqlConnection con = new SqlConnection(@"Data Source = LAPTOP-2A5CNVC3\SQLEXPRESS; Initial Catalog = Countries; Integrated Security = True");
    SqlCommand cmd = new SqlCommand();
    public Form1()
    {
    InitializeComponent();
    }
    private void btnClear_Click(object sender, EventArgs e)
    {
    dgvShowData.DataSource = null;
    }
    private void btnExit_Click_1(object sender, EventArgs e)
    {
    Application.Exit();
    }
    private void btnShow_Click_1(object sender, EventArgs e)
    {
    try
    {
    con.Open();
    cmd = new SqlCommand("Select * from Coutnry", con);
    cmd.ExecuteNonQuery();
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataTable dtable = new DataTable();
    da.Fill(dtable);
    dgvShowData.DataSource = dtable;
    con.Close();
    }
    catch
    {
    MessageBox.Show("Error 404");
    }
    }
    private void dgvShowData_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
    }
    }
    }

  • @VarunKumar-qd5wl
    @VarunKumar-qd5wl 4 ปีที่แล้ว +1

    Thank you