.net - C# - How can I set my Datagrid enabled = false and still have a scrollbar without using readonly()? -



.net - C# - How can I set my Datagrid enabled = false and still have a scrollbar without using readonly()? -

i requested create app read barcodes , update datatable on screen update database after info gathering.

the problem there's column must updated @ execution time every time barcode read, user shouldn't able edit cell writing on device keyboard.

so tried set columns readonly, when this, it's not possible update value on datatable, tried set datagrid enabled = false, scrollbar stopped working, , need because it's little device , there other columns user should able see.

is there simple way solve ? i'm using .net compact 3.5

this code button loads datagrid:

datatable tabela = new datatable(); datatable codbarras = new datatable(); private void button1_click(object sender, eventargs e) { ultimopedido = textbox1.text; seek { fbdatareader leitor; fbdatareader leitorbarras; string query1 = "select cast(0 double precision)separado, cast(itemorcamento.saldoitemorca - itemorcamento.quantitemseparado double precision)saldo, itemorcamento.quantitemseparado, itemorcamento.saldoitemorca, produto.produtoid, produto.refprod, produto.nomeprod, produto.estoqueped, itemorcamento.quantitemorca, itemorcamento.itemorcamentoid, orcamento.statusorca"; query1 += " orcamento "; query1 += " left bring together itemorcamento "; query1 += " on orcamento.orcamentoid = itemorcamento.orcamentoid "; query1 += " inner bring together produto "; query1 += " on itemorcamento.produtoid = produto.produtoid "; query1 += " orcamento.orcamentoid = " + textbox1.text + " , "; query1 += " orcamento.statusorca = 4 , "; query1 += " orcamento.separado = 0 , "; query1 += " itemorcamento.statusitemorca in (0,1) "; query1 += " order produto.produtoid"; string queryup = "update orcamento set separado = 1 orcamentoid =" + textbox1.text; leitor = conexao.executar(conexao.fbconexao, query1); tabela.load(leitor); if (tabela.rows.count > 0) { conexao.atualizar(conexao.fbconexao, queryup); datagrid1.datasource = tabela; datagridtablestyle ts = new datagridtablestyle(); datagridcolumnstyle celid = new datagridtextboxcolumn(); datagridcolumnstyle celquantitem = new datagridtextboxcolumn(); datagridcolumnstyle celsaldo = new datagridtextboxcolumn(); datagridcolumnstyle celref = new datagridtextboxcolumn(); ts.mappingname = tabela.tablename; celid.mappingname = "produtoid"; celid.headertext = "id"; celquantitem.mappingname = "separado"; celquantitem.headertext = "separado"; celsaldo.mappingname = "saldo"; celsaldo.headertext = "saldo"; celref.mappingname = "refprod"; celref.headertext = "referência"; celid.width = 50; celquantitem.width = 75; celsaldo.width = 50; celref.width = 75; ts.gridcolumnstyles.add(celid); ts.gridcolumnstyles.add(celquantitem); ts.gridcolumnstyles.add(celsaldo); ts.gridcolumnstyles.add(celref); datagrid1.tablestyles.add(ts); tabela.columns["separado"].readonly = true; textbox1.enabled = false; button1.enabled = false; textbox2.enabled = true; button6.enabled = true; button2.enabled = true; button3.enabled = true; button4.enabled = true; button5.enabled = true; } else { messagebox.show("não foram encontrados dados disponíveis"); } string query2 = "select b.codbarras, b.produtoid, b.itemorcamentoid" + " itemorcamento a" + " inner bring together codbarrasproduto b" + " on a.produtoid = b.produtoid" + " b.itemorcamentoid = 0 and" + " a.orcamentoid = " + textbox1.text + "and " + " b.itemorcamentoid = 0"; leitorbarras = conexao.executar(conexao.fbconexao, query2); codbarras.load(leitorbarras); } grab (exception e) { messagebox.show(e.message); } }

i think readonly collection might work you. http://msdn.microsoft.com/en-us/library/ms132474(v=vs.110).aspx

but there way too, can alter cell type label or textblock. need alter datagrid templates.

c# .net wpf datagrid compact-framework

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

java - Parsing XML, skip certain tags -

c# - ASP.NET MVC Sequence contains no matching element -