Dataset TableNewRow Event [solved]
-
i'm new in C#, whenever i'm going to create an event sub in vb.net, i choose event inside two combobox below page tab, but in C# it's totally different. then i figure it out by double clicking event properties, the sub will pop out in the code page. nah this time, it's about dataset (datatable) event, both method above isn't working. i've tried code converter and the output is "handles clauses are not supported in C#" any suggestion? uh and also, what's inside two combobox below page tab in C#? :doh:
-
i'm new in C#, whenever i'm going to create an event sub in vb.net, i choose event inside two combobox below page tab, but in C# it's totally different. then i figure it out by double clicking event properties, the sub will pop out in the code page. nah this time, it's about dataset (datatable) event, both method above isn't working. i've tried code converter and the output is "handles clauses are not supported in C#" any suggestion? uh and also, what's inside two combobox below page tab in C#? :doh:
The two combo boxes are easy - the left is all the classes in the current file - click on one and it will take you to the start of the definition. On the right are all the objects in the class - again, click to go to definition. The event adding in C# is the same for DataSet object (you can't add DataTables directly in the designer, so they are irrelevant here). Highlight the dataset, and look at the Properties pane. Click on the Lightning Bolt button to switch to the Events view, and double click the event - there are only three for a dataset anyway, and it it unlikely that you would want to handle any of them as a beginner in C# - Disposed, Initialized and MergeFailed are events I've not needed to override yet! :laugh: To add event handlers for a DataTable, you have to add it to the DataSet via it's Tables property, then select the table in the Property pane Objects drop down list. You can then access the events via the Lightening bolt button as before.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
The two combo boxes are easy - the left is all the classes in the current file - click on one and it will take you to the start of the definition. On the right are all the objects in the class - again, click to go to definition. The event adding in C# is the same for DataSet object (you can't add DataTables directly in the designer, so they are irrelevant here). Highlight the dataset, and look at the Properties pane. Click on the Lightning Bolt button to switch to the Events view, and double click the event - there are only three for a dataset anyway, and it it unlikely that you would want to handle any of them as a beginner in C# - Disposed, Initialized and MergeFailed are events I've not needed to override yet! :laugh: To add event handlers for a DataTable, you have to add it to the DataSet via it's Tables property, then select the table in the Property pane Objects drop down list. You can then access the events via the Lightening bolt button as before.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
yes, from the first time i'm confused of these two combobox in C#, i've use that lightning bolt (event) properties. the problem is, in dataset or even when i clicked datatable, there's no lightning bolt in properties page. :doh:
-
yes, from the first time i'm confused of these two combobox in C#, i've use that lightning bolt (event) properties. the problem is, in dataset or even when i clicked datatable, there's no lightning bolt in properties page. :doh:
The properties page is only relevant in the designer - not in the code window, if that's where you are clicking. You can't click a DataTable in the designer window directly - it doesn't have any UI element, so I assume you are highlighting the DataTable in the code window and trying to add an event? If so, then just on a new line in your code, type the name of the DataTable instance and press "." Intellisense will pop up a list of objects - select the event you want to add a handler for and type "+="
myDataTable.ColumnChanged+=
Intellisense will pop up a handler helper box:
new DataColumnChangeEventHandler(dt_ColumnChanged); (Press TAB to insert)
Press Tab to insert the text, and another box will appear:
Press TAB to generate Handler "dt_ColumnChanged" in this class
If you press Tab again, it will create a handler method stub for you to complete. Once you have the basic code, you can modify or tweak it to fit what you want to do !
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
The properties page is only relevant in the designer - not in the code window, if that's where you are clicking. You can't click a DataTable in the designer window directly - it doesn't have any UI element, so I assume you are highlighting the DataTable in the code window and trying to add an event? If so, then just on a new line in your code, type the name of the DataTable instance and press "." Intellisense will pop up a list of objects - select the event you want to add a handler for and type "+="
myDataTable.ColumnChanged+=
Intellisense will pop up a handler helper box:
new DataColumnChangeEventHandler(dt_ColumnChanged); (Press TAB to insert)
Press Tab to insert the text, and another box will appear:
Press TAB to generate Handler "dt_ColumnChanged" in this class
If you press Tab again, it will create a handler method stub for you to complete. Once you have the basic code, you can modify or tweak it to fit what you want to do !
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
namespace Documents.Objects.Datasets
{
public partial class dsDocuments
{
BooksDataTable. //even ctrl + space didn't work
}
}pardon me, i'm not really sure where to put the code, inside datatable class or dataset class, but wherever i put "BooksDataTable.", no intellisense is available. sorry i'm not used to C#, i'd be glad if you give me more information of this. ;P
-
namespace Documents.Objects.Datasets
{
public partial class dsDocuments
{
BooksDataTable. //even ctrl + space didn't work
}
}pardon me, i'm not really sure where to put the code, inside datatable class or dataset class, but wherever i put "BooksDataTable.", no intellisense is available. sorry i'm not used to C#, i'd be glad if you give me more information of this. ;P
Inside a method:
private DataTable BooksDataTable = new DataTable();
private void AddHandlers()
{
BooksDataTable.ColumnChanged += new DataColumnChangeEventHandler(BooksDataTable_ColumnChanged);
}void BooksDataTable_ColumnChanged(object sender, DataColumnChangeEventArgs e)
{
throw new NotImplementedException();
}Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
Inside a method:
private DataTable BooksDataTable = new DataTable();
private void AddHandlers()
{
BooksDataTable.ColumnChanged += new DataColumnChangeEventHandler(BooksDataTable_ColumnChanged);
}void BooksDataTable_ColumnChanged(object sender, DataColumnChangeEventArgs e)
{
throw new NotImplementedException();
}Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
thank you very much, i get it now. :laugh:
-
thank you very much, i get it now. :laugh:
Yes, of course! All you have to do is add the appropriate code to the DataTables in the DataSet.Tables property.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water