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
  1. Home
  2. General Programming
  3. C#
  4. please help me in DataGrid

please help me in DataGrid

Scheduled Pinned Locked Moved C#
helpquestion
1 Posts 1 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.
  • I Offline
    I Offline
    ImanMahmoud
    wrote on last edited by
    #1

    I have a datagrid that all of its columns are BoolColumnStyle and its DataSource is a table with no relations. I relate this DG with a counter, when I mark true or false in each DataGridCell the counter adds or subtracts (respectively) a certain number. Also I relate a TreeView with this DataGrid that the previous counter works separately for each TreeNode under the TopNode in this DataGrid. I used the following code to make my datagrid to respond to one click :

    private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    DataGrid.HitTestInfo hti = this.dataGrid1.HitTest(e.X, e.Y);
    try
    {
    if( hti.Type = = DataGrid.HitTestType.Cell )
    {
    int r = (int)hti.Row;
    int c = (int)hti.Column;
    DataRow dr = table.Rows[r];
    DataColumn dc = table.Columns[c];
    this.dataGrid1[r,c] = !(bool) this.dataGrid1[r,c];
    }
    }
    catch(Exception ex )
    {
    MessageBox.Show(ex.ToString());
    }
    } // dataGrid1_MouseUp

    I have the following problems : 1. The following message appears. I do not know what is the ListManeger or in other words, I do not understand what is the problem.

    The ListManeger’s position must be equal to the rowNum.
    Parameter name: rowNum Do you want to correct the value?

    2. The DataGrid responds to clicks even when there is no any TreeNodes are selected although I make a ckeck if (TreeView.TreeNode IsSelected). I want the DataGrid to respond to clicks only when any TreeNode under the TopNode is selected. 3. when the selected TreeNode is changed, I empty the DataGrid by the following code, but the last cell that I add a value to it remains checked :

    for(int i=0 ; iThe problems 1 and 3 disturb my counter.

    Please if there is a solution.

    Thank you

    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