473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Custom - DataGridViewColumn / DataGridViewCell

I am trying to create a custom DataGridViewCell which is "NOT" derived from
DataGridViewTextBoxColumn. The painting works fine but I am unable to get
the control into edit mode.

Do I need to manually handle the OnClick, something else, or is there
somewhy to set the edit control?

Edit type is called when the cell is clicked so it seems to be doing
something.

Regards,
John

class clsPMenuColumn : DataGridViewColumn
{
private System.Data.DataSet displayStrings;
public System.Data.DataSet DisplayStrings
{
set
{
this.displayStrings = value;
}
get
{
return this.displayStrings;
}
}

public override object Clone()
{
clsPMenuColumn cell = (clsPMenuColumn)base.Clone();
cell.DisplayStrings = this.DisplayStrings;

return cell;
}

public override DataGridViewCell CellTemplate
{
get
{
return base.CellTemplate;
}
set
{
if (value != null &&
!value.GetType().IsAssignableFrom(typeof(clsPMenuC ell)))
throw new InvalidCastException("Must be a Pmenu cell");

base.CellTemplate = value;
}
}
}
}

class clsPMenuCell : DataGridViewCell
{
private System.Data.DataSet DisplayStrings
{
get
{
if (base.OwningColumn is clsPMenuColumn)
return ((clsPMenuColumn)base.OwningColumn).DisplayStrings ;
return null;
}
}

public override object DefaultNewRowValue
{
get
{
return new clsMenuStructure();
}
}

public override Type EditType
{
get
{
return typeof(ctrlPMenuItem);
}
}

public override Type ValueType
{
get
{
return typeof(clsMenuStructure);
}
}

public clsPMenuCell() : base()
{
}

protected override void Paint(System.Drawing.Graphics graphics,
System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds,
int rowIndex, DataGridViewElementStates cellState, object value, object
formattedValue, string errorText, DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts
paintParts)
{
/// do painting here
}
}
Jul 27 '06 #1
1 10619
Never mind, had to hit F2 for edit mode.

Regards,
John
Jul 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: tsair | last post by:
When i add a new property into datagridviewcolumn, the property alway show null even i has been key in something in the property. how to solve this ? thank you
0
by: Tsair | last post by:
I create a custom DataGridViewColumn from a usercontrol with Textbox and a button. After input the usercontrol textbox value and press Tab to next column, the value of the textbox does not show in...
5
by: Tsair | last post by:
I do a customise DataGridColumn with a UserControl (TextBox + Button for Calender), DataGridView does not show the data content of the column.
2
by: Andy | last post by:
Hi all, I'm creating my own DataGridViewColumn class, and have added a string property to it which should be settable via the Property designer. I've gotten the property to show up, but even if...
7
by: SteveT | last post by:
I would like to create a customized DataGridViewColumn called DataGridViewCheckedListBoxColumn. I'd like the ability to multi-select items in the list. Does anyone know of an example of how this...
0
by: Franz | last post by:
I created a custom dataGridViewColumn which only accept numbers. For this Column, I can define a precision (number of decimal). I can set this property into my code, but not in design mode! ...
1
by: Charles Bazi | last post by:
Hi, Based on MSDN http://msdn2.microsoft.com/en-us/library/7tas5c80.aspx smple, I have made my custom DataGridViewColumn. I use it to host a custom control, sort of ComboBox, but instead of...
0
by: Katit | last post by:
I need to be able to custom color background of cells. When I do DataGridViewCell.Style.BackColor = Color.Yellow; It works properly as with any other enumerated color. When I try to do...
1
by: lbelkova | last post by:
Hello, I've created a custom DataGridViewColumn. Everything work well, except for some reason the column doesn't accept some of the chars: "q", "." and "'". Did anybody have a similar problem?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.