Ivan Climov

Ivan Climov

  • 1.1k
  • 692
  • 22.6k

How to hide a line in “gridControl1” and show this line in “

Dec 6 2018 1:26 AM
Devexpress 
 
How to hide a line in “gridControl1” and show this line in “gridControl2” if the user changes the value of the field? 
 
Theme update 
 https://www.c-sharpcorner.com/Forums/how-to-make-the-user-disappear-in-gridcontrol1-when-the-us
 
Scenario:
- User. Changes in gridControl1 in any line the value "???"("on") to the value "????"("off");
- Code. Hides the line in gridControl1 and displays the line in gridControl2;
I tried this using DataView, but it does not work.
How to make the scenario work?
 
 
 
 
  1. public partial class Frm13UC : UserControl  
  2. {  
  3.   
  4.         ConectDB conectDB;  
  5.   
  6.   
  7.   
  8.         public Frm13UC()  
  9.         {  
  10.             InitializeComponent();  
  11.         }  
  12.   
  13.         private void Frm12_Load(object sender, EventArgs e)  
  14.         {  
  15.             // ???????????  
  16.             conectDB = new ConectDB();  
  17.   
  18.         }  
  19.   
  20.   
  21.         public void FillGrid_1()  
  22.         {  
  23.             conectDB.connect();  
  24.   
  25.             gridControl1.DataSource = conectDB.dv1;  
  26.   
  27.             gridView1.BestFitColumns();  
  28.         }  
  29.   
  30.   
  31.         public void FillGrid_2()  
  32.         {  
  33.             conectDB.connect();  
  34.   
  35.             gridControl2.DataSource = conectDB.dv2;              
  36.   
  37.             gridView2.BestFitColumns();  
  38.         }  
  39. }  
  40.   
  41.   
  42. public class ConectDB  
  43. {  
  44.         public DataTable dt;  
  45.   
  46.         static OleDbDataAdapter adapter;  
  47.         static OleDbCommandBuilder cmdBuilder;  
  48.   
  49.         static GridControl gridControlThis;  
  50.   
  51.         public DataView dv1;  
  52.         public DataView dv2;  
  53.   
  54.         public ConectDB()  
  55.         {  
  56.   
  57.         }  
  58.   
  59.         public void connect()  
  60.         {  
  61.             string catBD = @"c:\vs\csharp\Db.accdb";  
  62.             string conBD = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", catBD);  
  63.   
  64.             OleDbConnection connection = new OleDbConnection(conBD);  
  65.   
  66.             connection.Open();  
  67.   
  68.             string query1 = "SELECT * FROM TableGrid_00";  
  69.             OleDbCommand cmd1 = new OleDbCommand(query1, connection);  
  70.   
  71.             dt = new DataTable();  
  72.   
  73.   
  74.             try  
  75.             {  
  76.                 adapter = new OleDbDataAdapter(cmd1);  
  77.                 cmdBuilder = new OleDbCommandBuilder(adapter);  
  78.                 adapter.UpdateCommand = cmdBuilder.GetUpdateCommand();  
  79.                 adapter.InsertCommand = cmdBuilder.GetInsertCommand();  
  80.   
  81.             }  
  82.             catch (Exception ex)  
  83.             {  
  84.                 string s = ex.Message;  
  85.                 throw;  
  86.             }  
  87.   
  88.             adapter.Fill(dt);  
  89.   
  90.             dv1 = new DataView(dt);  
  91.             dv1.RowFilter = "groupWork = '???'"// "on"  
  92.   
  93.             dv2 = new DataView(dt);  
  94.             dv2.RowFilter = "groupWork = '????'"// "off"  
  95.         }  
  96. }