Solved

prevent a particular datagrid column from being editable - c# sample included from SYNCFUSION

Posted on 2004-05-02
4
463 Views
Last Modified: 2008-02-01
i have a datagridcolumnstyle set up for my datagrid
this is the setup of the datagridcolumn that i do not want editable after it is filled

dim dgcDescription as DataGridTextBoxColumn
datagridtextboxColumn = new datagridtextboxColumn
datagridtextboxColumn.mappingName = "Description"
mytablestyles.gridcolumnstyles.add(datagridtextboxColumn)


i got the following sample from SYNCFUSION but i dont know how to implement the VB version and where to paste this.
i just need column1 to be non editable
------------------------------------------------------------------
You can do this by deriving a custom column style and overriding its virtual Edit member. Below is an override that will

prevent the cell in row 1 of the column from getting the edit focus. You can paste this code in the

DataGridDigitsTextBoxColumn sample to see it work.
//this override will prevent the cell in row 1 from getting the edit focus
 
protected override void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool

readOnly, string instantText, bool cellIsVisible)

{
     if(rowNum == 1)
          return;
     base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
}
------------------------------------------------------------------


could someone please tell me where to paste this and i reckon this.
my datagrid is called dgSale.
it is filled from a dataset.
0
Comment
Question by:jxharding
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 500 total points
ID: 10977817
Why not just set

dgcDescription.readonly = true
0
 

Author Comment

by:jxharding
ID: 10984612
thank you, its working fine.
would still like to know where to paste the code if someone has an answer.
thank you!
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 10984681
You need to create a new class which inherits from datagridtextboxColumn and paste the above code in your new class
 if you need a code example let me know
0
 

Author Comment

by:jxharding
ID: 10984796
i thought there was i shorter way maybe just using that little section of code. ill just use the sample from SYNCFUSION
thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question