Reputation: 184
I'm developing for a smart device (windows ce 6.5) under the 3.5 net compact framework.
What i'm trying to do is to add a simple button to a DataGrid (not a datagridview, they don't exist for this framework).
Since there is no Button for the DataGrid you have to develop your own control.
I read the following code to give me an idea
https://www.akadia.com/services/dotnet_combobox_in_datagrid.html
But once i got to the part of actually adding the control to the DataGrid, i hit a roadblock since i cant seem to find the way to access the parent.
In the original code they do access it thru the TextBox reference.
// The Edit event is raised when the user sets the focus to the cell
// containing the combobox. In this event the dimensions of the combobox
// are set and an event handler is assigned to handle scrolling of the combobox.
protected override void Edit(
CurrencyManager source,
int rowNum,
Rectangle bounds,
bool readOnly,
string instantText,
bool cellIsVisible)
{
base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
// Attach the Combobox to the same Parent Control
// as the TextBox of the DataGrid
myComboBox.Parent = this.TextBox.Parent;
}
But in the compact .net framework the DataGridTextBoxColumn class does not have that reference.
This is my current control.
public class DataGridButtonColumn:DataGridTextBoxColumn
{
private Button _button;
public DataGridButtonColumn()
{
_button = new Button();
_button.Width = 50; //default size
_button.BackColor = Color.Gray; //default color
}
public Button DataGridButton
{
get { return _button; }
}
protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
{
base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
}
}
Any idea on how this can be accomplished?
Upvotes: 0
Views: 339