Click here to Skip to main content
16,004,969 members
Home / Discussions / C#
   

C#

 
QuestionDataset/DataTable with DataGrid (local database only!) Pin
Blubbo19-Dec-06 3:38
Blubbo19-Dec-06 3:38 
AnswerRe: Dataset/DataTable with DataGrid (local database only!) Pin
Private_Void19-Dec-06 7:43
Private_Void19-Dec-06 7:43 
GeneralRe: Dataset/DataTable with DataGrid (local database only!) Pin
Blubbo19-Dec-06 7:49
Blubbo19-Dec-06 7:49 
GeneralRe: Dataset/DataTable with DataGrid (local database only!) Pin
Private_Void19-Dec-06 8:39
Private_Void19-Dec-06 8:39 
GeneralRe: Dataset/DataTable with DataGrid (local database only!) Pin
Blubbo19-Dec-06 8:53
Blubbo19-Dec-06 8:53 
GeneralRe: Dataset/DataTable with DataGrid (local database only!) Pin
Private_Void19-Dec-06 9:47
Private_Void19-Dec-06 9:47 
QuestionDataGridView and new rows Pin
Wjousts19-Dec-06 3:25
Wjousts19-Dec-06 3:25 
AnswerRe: DataGridView and new rows Pin
Lisa Jorgensen23-Dec-06 16:18
Lisa Jorgensen23-Dec-06 16:18 
One approach is to add a handler for the BindingSource's AddingNew event. E.g.:
C#
InitializeGrid()
{
    // Create sample List of custom objects. First object uses a non-default
    // constructor, the second uses the default (no reason, just seemed
    // like something to do in the example).

    List<CustomItem> sourceList = new List<CustomItem>();
    CustomItem firstItem = new CustomItem("Special content");
    sourceList.Add(firstItem);
    CustomItem nextItem = new CustomItem();
    sourceList.Add(nextItem);

    // Create the BindingSource, add the list, and add an event handler
    // for the AddingNew event.

    BindingSource bindingSource = new BindingSource();
    bindingSource.DataSource = sourceList;
    bindingSource.AddingNew += new AddingNewEventHandler(bindingSource_AddingNew);

    // Bind to the DataGridView.

    dataGridView.DataSource = bindingSource;
}

C#
private void bindingSource_AddingNew(object sender, AddingNewEventArgs e)
{
    // Use non-default constructor for the new object that will
    // be the source for the new row.

    e.NewObject = new CustomItem("Not default content");
}

An alternative is to use the DataGridView's DefaultValuesNeeded event, but the object has already been constructed by the time this event fires.
QuestionInconsistent Connection Pooling Behavior Pin
Jason Pease19-Dec-06 3:16
Jason Pease19-Dec-06 3:16 
AnswerRe: Inconsistent Connection Pooling Behavior Pin
althamda19-Dec-06 3:23
althamda19-Dec-06 3:23 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
Jason Pease19-Dec-06 3:32
Jason Pease19-Dec-06 3:32 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
althamda19-Dec-06 3:45
althamda19-Dec-06 3:45 
AnswerRe: Inconsistent Connection Pooling Behavior Pin
Guffa19-Dec-06 4:12
Guffa19-Dec-06 4:12 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
Jason Pease19-Dec-06 5:03
Jason Pease19-Dec-06 5:03 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
Guffa19-Dec-06 5:13
Guffa19-Dec-06 5:13 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
Jason Pease19-Dec-06 5:31
Jason Pease19-Dec-06 5:31 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
althamda19-Dec-06 5:39
althamda19-Dec-06 5:39 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
Guffa19-Dec-06 5:42
Guffa19-Dec-06 5:42 
AnswerRe: Inconsistent Connection Pooling Behavior Pin
Pete O'Hanlon19-Dec-06 10:47
mvePete O'Hanlon19-Dec-06 10:47 
QuestionSmart Card Library (scardssplib) Help Pin
s.jahangiri19-Dec-06 2:46
s.jahangiri19-Dec-06 2:46 
Questionalthamda Pin
nima136319-Dec-06 2:44
nima136319-Dec-06 2:44 
AnswerRe: althamda Pin
althamda19-Dec-06 2:57
althamda19-Dec-06 2:57 
QuestionForms Pin
quiteSmart19-Dec-06 2:36
quiteSmart19-Dec-06 2:36 
AnswerRe: Forms Pin
netJP12L19-Dec-06 2:57
netJP12L19-Dec-06 2:57 
Questionalthamda thanks a lot Pin
nima136319-Dec-06 2:33
nima136319-Dec-06 2:33 

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.