|
To disallow users from clicking or selected a particular column, you will have to use custom table style for your data grid. In this custom table style you will have to add custom data column styles - DataGridTextBoxColumn.
Derive a class from DataGridTextBoxColumn and in that override the Edit method and in that method do nothing.
public class MyTextBoxColumn : DataGridTextBoxColumn
{
public MyTextBoxColumn()
{
//
// TODO: Add constructor logic here
//
}
protected override void Edit(...)
{
if (!ReadOnly)
{
base.Edit(..); // call base class
}
//don't call baseclass, so no editing....
}
}
This should take care of it!
Hope this helps.
Suhas
|
|
|
|
|
Hi Suhas,
I tried what you said but it's not working the way I implemented it. I'll explain what I did.
//Create a custom Column Style for the 1st Col: Questions
CurrencyManager cm = (CurrencyManager)this.BindingContext[dtTable];
PropertyDescriptor pd = cm.GetItemProperties()[0];//Get Prop for the 1st col
MyControls.MyDataGridTextBoxColumn myColStyle = new MyControls.MyDataGridTextBoxColumn(pd);
newGrid[indexPage].TableStyles.Add(dgdtblStyle);
newGrid[indexPage].TableStyles[0].GridColumnStyles.Add(myColStyle);
And to create the MyControl Class:
public class MyDataGridTextBoxColumn: DataGridTextBoxColumn
{
public MyDataGridTextBoxColumn(PropertyDescriptor pd) : base(pd)
{ }
protected override void Edit(CurrencyManager cm, int rowNum, Rectangle bounds, bool readOnly)
{
MessageBox.Show("in Edit");
if (!readOnly)
base.Edit(cm, rowNum, bounds, readOnly);
}
}
But that MessageBox is bever clicked & nothing diff happens when I try to edit the 0th Col !
What do you think I am doing wrong ?
Thanks.
Paul
|
|
|
|
|
Hi,
I put a label on top of that column in the data grid & now u cannot edit the text in that column. But if u click on any editable control like combo box in the datagrid, or even at any place in the grid where there are no rows, the first row gets selected ... What's happening !?!
I was able to remove that extra row with AllowNew property set to false.
Thanks for all ur help. But I think we need a much stronger DatagRid than what we have right now !
Paul
|
|
|
|
|
pahluwalia@hotmail.com wrote:
newGrid[indexPage].TableStyles.Add(dgdtblStyle);
newGrid[indexPage].TableStyles[0].GridColumnStyles.Add(myColStyle);
Add custom column styles to the custom table style AND then add the custom table style to the datagrid's table style collection. If you do the reverse, the way you have done, the data grid will not use your column styles
|
|
|
|
|
To see ComboBox in DataGrid always - try to override Paint method in suhass'es example. To avoid extra row set DataGrid ListManager protected property:
(DataView)(myDataGrid.ListManager.List).AllowNew=false;
Hi,
AW
|
|
|
|
|
I was able to avoid that extra row the way you said.
Is there a way to have Vertical Scrolling on in a DataGrid ?
Thanks
|
|
|
|
|
I am wanting to create my own "Item" for use in the "File|Add New Item" dialog window. Does anyone know of any resources which would point me in the right direction?
FYI: The item I want to create is an option to add a StronglyTypedCollection class.
Thanks.
Mark Sanders
Lowrance Electronics, Inc.
|
|
|
|
|
Can someone explain how to use the BHO that comes with IE?
|
|
|
|
|
|
Hi all,
In my project, i'm using a third party ActiveX component.
Right clicking the component during runtime will display a popup menu.
My problem is that i want to disable it ( or disable some of the options in the menu). Is it possible ?
Mahesh
|
|
|
|
|
Yes, if there is some property which exposes the inner objects. component Documentation might helps you.
Regards.
NetPointer
|
|
|
|
|
|
There is a find/replace dialog in the Genghis project[^]
Hope this helps
- Kannan
|
|
|
|
|
I am sure this question has a simple answer and when I see it I will scream like a girl, but such is the way of things.
I have a ComboBox (cmbImportance) which is populated from a dataset with the following code :
cmbImportance.Items.Clear();
cmbImportance.ValueMember = "id";
cmbImportance.DisplayMember = "level";
cmbImportance.DataSource = ds.Tables[0];
This gives me a ComboBox with these values :
Critical (Selected)
High
Normal
Low
So far so good, the thing is this combo is also used to display properities that somebody has previously selected and may want to edit - if the form is displaying previously selected values I use the following code to select the users previous selection
if (edit_view)
{
cmbImportance.SelectedItem = user_prefs.importance;
}
Which all seems relatively simple, but lets assume that the previously selected importance is "Normal" what happens is that I end up with a combo box with the following values :
NormalCritical (selected)
High
Normal
Low
Obviously the 'NormalCritical' select object is wrong, but I cant work out why it is doing this - I have tried used SelectedText as well and it did the same thing.
|
|
|
|
|
I have found a solution to this little problem, and that is to use this code to select items instead :
cmbImportance.SelectedIndex = cmbImportance.FindStringExact(user_prefs.importance);
Which is all well and good, but I am lost as to an explaination of why this works and the other method did not
|
|
|
|
|
What about
cmbImportance.SelectedItem = cmbImportance.Items.IndexOf(user_prefs.importance);
|
|
|
|
|
I've written a quick and dirty image object that accepts parameters along the url to generate either a resized image or captions.
It takes parameters something like this:
The problem, which is a ticklish one, is that it seems to strip out the acute and graves from the end image, leaving nothing in it's place.
In the codebehind I've specified:
myGraphics.DrawString(Caption, CaptionFontFamily, new SolidBrush(CaptionColour), CaptionXRegister, CaptionYRegister, new StringFormat(StringFormatFlags.NoFontFallback)); to ensure that the characters won't be substituted with anything else. This has not resolved the problem. Been looking for a couple of hours for the answer to no avail. I've also tried setting the culture in the web.config file by the way...
Any ideas would be much appreciated
As I thought that C# uses UTF8 by default, this is indeed confusing me....
|
|
|
|
|
HTTP uses a special encoding for some chars, e.g., accented chars. When the browser is sending the GET request for the image, it's probably messing up with the char.
See the MSDN documentation for HttpServerUtility.UrlEncode or HttpUtility.UrlEncode methods.
You can do it on anything you choose - from .bat to .net - A customer
|
|
|
|
|
I need to create a "package" including some pictures, sounds, and ini file.
My first idea is top compress all of themp into a zip file, change the extension to .app.
I would need to do it programatically in C#, and be able to access a given file in the zip. For instance, read only the ini to get some general information, and list the contents of the package, and then open the package when asked.
Is it possible?
|
|
|
|
|
Yes:
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
You can do it on anything you choose - from .bat to .net - A customer
|
|
|
|
|
Yes it is possible.
Check out this[^] article on msdn.
The only problem is when you ship the application you need to ship the vj# redistributable.
- Kannan
|
|
|
|
|
Look at my Bzlib managed wrapper article right here on CP!
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
hi,
any method prevent the window close when user click the "little cross" button at the right top corner of the window.
in other word, would i can to get the window close message invoke by the "little cross" button? so, i can re-route the message to prevent window close.
anyone would help?
thanks,
jim
|
|
|
|
|
I'm not sure of the exact syntaxe because I don't have Visual Studio .Net installed. But you can simply select the event closing (I hope it's this one). Then, in the event arg, you can simply use
e.Cancel = true;
to cancel the event, i.e. prevent the window close.
Of course, you could also remove the "little cross" button.
|
|
|
|
|
First subscribe to the Closing event:
this.Closing += new System.ComponentModel.CancelEventHandler(Form_Closing);
Then use the CancelEventArgs.Cancel property to abort closing:
private void Form_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
}
|
|
|
|