Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. datagridview help needed

datagridview help needed

Scheduled Pinned Locked Moved C#
questioncsharphelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    giddy_guitarist
    wrote on last edited by
    #1

    hi , could someone please help me out with the datagridviewer? i'm new to C# , dont have much of any idea about it. i'm building a booking program for a little hotel. I need : 1. to have a context menu thats cell specific , i know i can use the datagrid contextmenu prop. or handle the cellcontextmenuneeded event , but if i right click on a cell the focus does'nt change to that cell , i have options on the menu that pertain to single cells like excel. 2. How do i restrict the user from adding new rows or deleting existing rows , but he should still be able to edit the text in the cells. 3. i have two tables , one is a status table with status for all rooms .. it has 2 cols. roomID and customerName. The second table is a customers table with all the cutomers details and customerName. Now the customerName col. in both the tables should be related , the datagridview has 25 rows each for a room , it should scan the status table for each room , and load the corresponding customers details into the datagridview. How do i make a relation and do the above? i need this a little quick so please help! Thanks in advance Gideon

    R 1 Reply Last reply
    0
    • G giddy_guitarist

      hi , could someone please help me out with the datagridviewer? i'm new to C# , dont have much of any idea about it. i'm building a booking program for a little hotel. I need : 1. to have a context menu thats cell specific , i know i can use the datagrid contextmenu prop. or handle the cellcontextmenuneeded event , but if i right click on a cell the focus does'nt change to that cell , i have options on the menu that pertain to single cells like excel. 2. How do i restrict the user from adding new rows or deleting existing rows , but he should still be able to edit the text in the cells. 3. i have two tables , one is a status table with status for all rooms .. it has 2 cols. roomID and customerName. The second table is a customers table with all the cutomers details and customerName. Now the customerName col. in both the tables should be related , the datagridview has 25 rows each for a room , it should scan the status table for each room , and load the corresponding customers details into the datagridview. How do i make a relation and do the above? i need this a little quick so please help! Thanks in advance Gideon

      R Offline
      R Offline
      Rey9999
      wrote on last edited by
      #2

      1 - it's a little tricky, give me some time to think about it. 2 - in the smart tag of the datagridview, uncheck "enable adding" option 3 - a binding source could help you.

      ~~~ From Milano to The Hague, easy as it goes ~~~

      G 1 Reply Last reply
      0
      • R Rey9999

        1 - it's a little tricky, give me some time to think about it. 2 - in the smart tag of the datagridview, uncheck "enable adding" option 3 - a binding source could help you.

        ~~~ From Milano to The Hague, easy as it goes ~~~

        G Offline
        G Offline
        giddy_guitarist
        wrote on last edited by
        #3

        hey , i got it! i dont know much but it works perfect this way: private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { dataGridView1.CurrentCell = DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex]; this.dataGridView1.ContextMenuStrip = this.contextMenuStrip1; } works only on this event ... and yes the contextStrip shows up when i right click . not when i left click thanks so much for your concern!:):) but i got another problem now.. .basically.. .the datagrid on my form shoud display the status of ALL the rooms... for a given date(i have a datepicker on the form) .. ok so now in my test app. when i hit 8th on the datepicker , the DGV shows one entry .. room 103A is booked on that date. Problem is , it only shows one entry .. i want the empty rooms to show up as empty rows. I know i have to add unbound data. I tried to add blank rows. but its says i cannot add anythign programmatically if i have it bound. If its unbound this is how i add the rows .. DataRow dt = dataSet.Tables["customers"].Rows[0]; dataGridView2.Rows.Add(dt[0] , dt[1] , dt[2] ....... ); is the above correct or is there a better way...?? also if i add the blank rows .. and the user adds something in it what event do i have to handle? and how do i update/add the DB manually? :confused:i know SQL .. i'm using oledb . for an access database (.mdb) now one of the colums inthe database is roomtype. but then when i load the values i want them in a combobox? how do i do that? how do i adda combobox to the DVG?:sigh: DataGridViewComboBoxColumn cboColumn = new DataGridViewComboBoxColumn(); cboColumn.Items.Add("a"); cboColumn.Items.Add("b"); dataGridView2.Rows.Add("", cboColumn, ""); i get -> DataGridViewComboBoxColumn { Name=, Index=-1 } in the second column!:doh: :doh: plz help!:sigh:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups