|
It's actually on the DataTable class, along with several other events. The DataGrid is implemented abstractly, working with any data source that implements IList or IListSource . Anything specific to how that data is manipulated would be specific to the data source. In this case, all the events you'd need for knowing when a row was inserted, changed, or deleted are defined on the DataTable class. See the class member documentation in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
As far as I can see there is no event for when a row is inserted. If there is can you tell me what the event is called. anybody?
|
|
|
|
|
Handle DataTable.RowChanging or DataTable.RowChanged (whichever is appropriate). The DataRowChangeEventArgs.Action specifies whether a DataRow is being added, changed, committed, deleted, or rollbacked.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
It is possible to lock the Excel process my app creates at runtime so that if the PC user opens another Excel file it does not get opened into 'my' excel process?
Would this be an Excel thing that I can control?
|
|
|
|
|
There is no way to "lock" the Excel process.
You can't really handle the WorkbookLoad event either, because that event fires AFTER the new workbook is loaded...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I've had this crazy idea in one of my personal projects to have a go at skinning a bit like WindowBlinds (think just my app for now).
My question is how do you draw on the area outside of the ClipRectangle? I need to be able to draw where the current XP theme is usually drawn.
For example where the control box is on a form.
Anyone got any ideas on this?
Thanks
|
|
|
|
|
You need to override WndProc in your Form derivative and handle the WM_NCPAINT (0x0085) notification message. See the documentation for the WM_NCPAINT message in the Platform SDK in the MSDN Library Online[^] for more information about the WPARAM and LPARAM values. I will tell you the WPARAM is the HRGN (handle to a region) that you can wrap in a .NET Region class using the static Region.FromHrgn method. To get a Graphics object, P/Invoke GetDCEx to get the HDC (handle to a device context) for the HRGN . You can then use Graphics.FromHdc to get a Graphics object. Just be sure to call Graphics.ReleaseHdc then Graphics.Dispose when you're done drawing otherwise you'll have a memory leak.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks i'll give that a shot
|
|
|
|
|
I am working on this same issue. I use a standard form with no title bar or controls. I then put placeholder images for the standard items like titlebar, control box, form control buttons. I then read in from a skin file what images to use for what items and where the position needs to be. This way I can even use a background image that is non-rectangular with regions to create a nicely skinned application.
Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!
Visit my Code Project blog (Mobile Audio project)[^]
|
|
|
|
|
I would like to retrieve the IP address assigned to my machine from a VPN connection. Obviously I can go Dns.GetHostByName(Dns.GetHostName()).AddressList to get the list of addresses assigned to my local machine, and this does indeed return both my LAN address and my VPN address, however, is it possible to distiguish in code which address is my VPN address and which one is my LAN address?
#include "witty_sig.h"
|
|
|
|
|
You'll either have to use:
1) The Win32 API IPHelper functions to iterate through the network adapters and get the addresses for each of them
or
2) Use the System.Management classes (WMI) to iterate through the adapters, looking for the VPN adapter. The class to find in the WMI query will be Win32_NetworkAdapter .
There is no ".NET Way" to do this...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Shucks. Thanks for the information.
#include "witty_sig.h"
|
|
|
|
|
I have a form that contains 200 textboxes in a table format, all named the same except with a number appended (i.e tbName1-tbName200). If I want to process these textboxes in a loop to capture the text values, how should I do this? Do I look for all of the components in the form and examine each component to see if it matches the name I'm looking for; seems to me that this is a difficult way to find the actual textbox object.
--Mike
|
|
|
|
|
You could add a Panel or GroupBox behind the TextBoxes, then just iterate through the control in the Panel or GroupBox.
The following is just an shove in the right direction, I believe this approach will work.
private void CycleTextBoxes()
{
foreach( Control ctrl in gbTextBoxGroupBox.Controls)
{
TextBox tbTemp = (TextBox)ctrl;
if(tbTemp!=null)
{
}
}
}
|
|
|
|
|
You will get an exception. Instead, use TextBox tbTemp = ctrl as TextBox; The as keyword performs a safe cast, returning null if the cast isn't valid instead of throwing an InvalidCastException . If that cast wasn't valid, only then when tbTemp be null.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The following is code for manipulating INI files:
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
...
...
...
public class INI
{
public INI(string Path)
{
INIPath = Path;
}
public string INIPath=null;
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,string key,string val,string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section,string key,string def,StringBuilder retVal,int size,string filePath);
[DllImport("kernel32")]
private static extern int WritePrivateProfileSection(string section,string Entries,string filePath);
public void ClearSection(string SectionName)
{
WritePrivateProfileSection(SectionName,"",this.INIPath);
}
public void WriteINI(string Section,string Key,string Value)
{
WritePrivateProfileString(Section,Key,Value,this.INIPath);
}
public string GetINI(string Section,string Key,string DefaultValue)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section,Key,"",temp,255,this.INIPath);
if(i==0 && DefaultValue!="NOADD")
{
WriteINI(Section,Key,DefaultValue);
return DefaultValue;
}
if(i==0 && DefaultValue=="NOADD")
return "NOADD";
return temp.ToString();
}
}
|
|
|
|
|
Try to use this function
private void avoidTextboxes()
{
FieldInfo[] fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
TextBox _btn;
foreach (FieldInfo fi in fields){
if (null != (_btn = fi.GetValue(this) as TextBox))
{
_btn.Text += " was modified";
}
}
}
xedom developers team
|
|
|
|
|
Thanks to you all for your time and suggestions, I'll try some of them out. Since I'm processing an input form of 21 columns x 25 rows, for each textbox name, if I loop through all of controls to find the textbox's text value, I'll potentially be doing this hundreds of times for each one.
So what I may use is a HashTable to store the TextBox's name and the TextBox Object so I can look for the key and then if it's there, just get the TextBox object and it's associated Text value. Any thoughts on this?
--Mike
|
|
|
|
|
Hi Everyone,
Is it possible to create a dotNet MDI app (C#) and use pinvoke to
create win32 client forms? This would mean using the CreateWindowEx
function and possibly sending over the dotNet parent Handle. If you
can do this, what steps should I take and watch out for? For example,
do I need to send over the HINSTANCE of the app and/or do I need to
set the MdiParent to the win32 child. Lots of questions here. Any
help would be totally awesome!
Cheers guys,
DrD.
|
|
|
|
|
Why on earth would you want to? The Form class is a wrapper for the Win32 Window class to begin with, so your already using the Win32 "Form" class.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Basically I have an existing program that pumps out OpenGL graphics to a win32 window. This window is created using CreateWindowEx. I now want to put a dotNet front to it and make it a client window of dotNet MDI. It sounds simple enough but I'm not sure how to set this up properly. Any ideas?
|
|
|
|
|
I've never even thought of attempting something like this. Can you get the OpenGL library to draw it's contents on a device context that you specify?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok, after tinkering around I've solved the problem. Basically I used interop to get down into win32 and used CreateWindowEx. At this stage I did not create a MDI child window but created a normal window. Once created (but before shown) I called "SetParent" and made this new window point to the dotNet main frame. I passed in the dotNet MDI frame handle to my win32 code dll. This worked a treat and I'm happy with the result. However, in doing this you will need to manage resize issues etc yourselves eg) using CreateWindowRect and the like.
Just to note, before I stumbled onto this I was trying to create a MDI child window using CreateWindowEx and it wasn't working at all. I guess this was due to some compatibility problem between dotNet/win32. Anyone else know why -or- have got it working like this?
Cheers,
SPM
|
|
|
|
|
i am a begineer in c#,and am not getting exact technical terms to explain my problem, though i shall try my best.i have developed a program which takes values from a textbox. its obvious that when i run the program for second time the previously entered values through textbox will get wiped out & textbox will ask for new values. how do i avoid this? how do i make program to run as may times as i want on the values i entered for first time when i ran the program? & only take new values when i change the contents of textbox & continue with this values for any number of times i run the program.
|
|
|
|
|
You need to write the initially entered value to a file or registry someplace. The most commplace is either an INI file or the Registry.
|
|
|
|