Click here to Skip to main content
15,897,315 members
Home / Discussions / C#
   

C#

 
GeneralNETBIOS Pin
Y3YPnATOP18-Nov-04 22:06
Y3YPnATOP18-Nov-04 22:06 
GeneralRe: NETBIOS Pin
Heath Stewart19-Nov-04 8:35
protectorHeath Stewart19-Nov-04 8:35 
GeneralDataGrid control Pin
sasan5618-Nov-04 20:30
sasan5618-Nov-04 20:30 
GeneralRe: DataGrid control Pin
DougW4818-Nov-04 20:38
DougW4818-Nov-04 20:38 
GeneralRe: DataGrid control Pin
drayab18-Nov-04 20:51
drayab18-Nov-04 20:51 
GeneralDataGridTimePickerColumn question Pin
Old Gun18-Nov-04 16:22
Old Gun18-Nov-04 16:22 
GeneralRe: DataGridTimePickerColumn question Pin
Heath Stewart19-Nov-04 8:38
protectorHeath Stewart19-Nov-04 8:38 
GeneralRe: DataGridTimePickerColumn question Pin
Old Gun20-Nov-04 21:06
Old Gun20-Nov-04 21:06 
Thanks a lot!

this my code
DataGridTimePickerColumn tpcsCreatedDate = new DataGridTimePickerColumn();
tpcsCreatedDate.MappingName = "CreatedDate";
tpcsCreatedDate.HeaderText = "CreatedDate";
tpcsCreatedDate.NullText = DateTime.Now.ToShortDateString();
myGridStyle.GridColumnStyles.Add(tpcsCreatedDate);





this is DataGridTimePickerColumn from msdn
using System;
using System.Data;
using System.Windows.Forms;
using System.Drawing;

// This example shows how to create your own column style that
// hosts a control, in this case, a DateTimePicker.
public class DataGridTimePickerColumn : DataGridColumnStyle
{
private DateTimePicker myDateTimePicker = new DateTimePicker();
// The isEditing field tracks whether or not the user is
// editing data with the hosted control.
private bool isEditing;

public DataGridTimePickerColumn() : base()
{
myDateTimePicker.Visible = false;
}

protected override void Abort(int rowNum)
{
isEditing = false;
myDateTimePicker.ValueChanged -=
new EventHandler(TimePickerValueChanged);
Invalidate();
}

protected override bool Commit
(CurrencyManager dataSource, int rowNum)
{
myDateTimePicker.Bounds = Rectangle.Empty;

myDateTimePicker.ValueChanged -=
new EventHandler(TimePickerValueChanged);

if (!isEditing)
return true;

isEditing = false;

try
{
DateTime value = myDateTimePicker.Value;
SetColumnValueAtRow(dataSource, rowNum, value);
}
catch (Exception)
{
Abort(rowNum);
return false;
}

Invalidate();
return true;
}

protected override void Edit(
CurrencyManager source,
int rowNum,
Rectangle bounds,
bool readOnly,
string instantText,
bool cellIsVisible)
{
DateTime value = (DateTime)
GetColumnValueAtRow(source, rowNum);
if (cellIsVisible)
{
myDateTimePicker.Bounds = new Rectangle
(bounds.X + 2, bounds.Y + 2,
bounds.Width - 4, bounds.Height - 4);
myDateTimePicker.Value = value;
myDateTimePicker.Visible = true;
myDateTimePicker.ValueChanged +=
new EventHandler(TimePickerValueChanged);
}
else
{
myDateTimePicker.Value = value;
myDateTimePicker.Visible = false;
}

if (myDateTimePicker.Visible)
DataGridTableStyle.DataGrid.Invalidate(bounds);
}

protected override Size GetPreferredSize(
Graphics g,
object value)
{
return new Size(100, myDateTimePicker.PreferredHeight + 4);
}

protected override int GetMinimumHeight()
{
return myDateTimePicker.PreferredHeight + 4;
}

protected override int GetPreferredHeight(Graphics g,
object value)
{
return myDateTimePicker.PreferredHeight + 4;
}

protected override void Paint(Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum)
{
Paint(g, bounds, source, rowNum, false);
}
protected override void Paint(
Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum,
bool alignToRight)
{
Paint(
g,bounds,
source,
rowNum,
Brushes.Red,
Brushes.Blue,
alignToRight);
}
protected override void Paint(
Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum,
Brush backBrush,
Brush foreBrush,
bool alignToRight)
{
DateTime date = (DateTime)
GetColumnValueAtRow(source, rowNum);
Rectangle rect = bounds;
g.FillRectangle(backBrush,rect);
rect.Offset(0, 2);
rect.Height -= 2;
g.DrawString(date.ToString("d"),
this.DataGridTableStyle.DataGrid.Font,
foreBrush, rect);
}

protected override void SetDataGridInColumn(DataGrid value)
{
base.SetDataGridInColumn(value);
if (myDateTimePicker.Parent != null)
{
myDateTimePicker.Parent.Controls.Remove
(myDateTimePicker);
}
if (value != null)
{
value.Controls.Add(myDateTimePicker);
}
}

private void TimePickerValueChanged(object sender, EventArgs e)
{
this.isEditing = true;
base.ColumnStartedEditing(myDateTimePicker);
}
}



please give me some more help!

QuestionHow to perform carriage return by coding,not by clicking the Enter key? Pin
momer18-Nov-04 16:04
momer18-Nov-04 16:04 
AnswerRe: How to perform carriage return by coding,not by clicking the Enter key? Pin
Daniel Turini18-Nov-04 20:41
Daniel Turini18-Nov-04 20:41 
AnswerRe: How to perform carriage return by coding,not by clicking the Enter key? Pin
Luis Alonso Ramos19-Nov-04 9:03
Luis Alonso Ramos19-Nov-04 9:03 
Generaldatagrid slow updating Pin
bwagz18-Nov-04 14:21
bwagz18-Nov-04 14:21 
GeneralArrayList in ArrayList Pin
stumpi18-Nov-04 13:52
stumpi18-Nov-04 13:52 
GeneralRe: ArrayList in ArrayList Pin
maibuihuynhtg18-Nov-04 16:43
maibuihuynhtg18-Nov-04 16:43 
GeneralOverriding soap interpretation of specific types Pin
WildRide18-Nov-04 13:32
WildRide18-Nov-04 13:32 
GeneralRe: Overriding soap interpretation of specific types Pin
steve_hocking19-Nov-04 3:23
steve_hocking19-Nov-04 3:23 
QuestionHow can i get the ID3 info on MP3s Pin
visiontec18-Nov-04 13:30
visiontec18-Nov-04 13:30 
AnswerRe: How can i get the ID3 info on MP3s Pin
Leon van Wyk18-Nov-04 22:07
professionalLeon van Wyk18-Nov-04 22:07 
GeneralOverriding Object.Equals; Overriding Object.GetHashCode Pin
McClamm18-Nov-04 12:07
McClamm18-Nov-04 12:07 
GeneralRe: Overriding Object.Equals; Overriding Object.GetHashCode Pin
Daniel Turini18-Nov-04 20:45
Daniel Turini18-Nov-04 20:45 
GeneralDeclaring arrays of class objects Pin
Steve Searcy18-Nov-04 9:20
Steve Searcy18-Nov-04 9:20 
GeneralRe: Declaring arrays of class objects Pin
Daniel Turini18-Nov-04 10:05
Daniel Turini18-Nov-04 10:05 
GeneralDataGrid Header in Windows Application Pin
Hamada_star18-Nov-04 6:28
Hamada_star18-Nov-04 6:28 
GeneralC# Datagrid Separate Column Header Font Colors Pin
StyleGuide18-Nov-04 5:13
StyleGuide18-Nov-04 5:13 
QuestionHow to create automatic updates ? Pin
Inquire2you18-Nov-04 4:14
Inquire2you18-Nov-04 4:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.