Solved

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

Posted on 2004-05-02
4
457 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
  • 2
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 500 total points
Comment Utility
Why not just set

dgcDescription.readonly = true
0
 

Author Comment

by:jxharding
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now