|
Thanks mav.northwind!
I was just testing V|ktor's code and was wondering abt Casing and the Spaces too.
|
|
|
|
|
i wrote this code to delete a record.
string STOCKConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ALOHA_PATH + "\\stockcontrol;Extended Properties=dBase IV";
OleDbConnection STOCKConnection = new OleDbConnection(STOCKConnString);
string colID;
colID= this.dataGrid1[index,0].ToString();
string STOCKUpQuery = "Delete * From STOCK.DBF Where ID=("+colID+")";
OleDbCommand STOCKUpCommand = new OleDbCommand(STOCKUpQuery,STOCKConnection);
STOCKConnection.Open();
STOCKUpCommand.ExecuteNonQuery();
STOCKConnection.Close();
this record is deleted from stock.dbf, but i can still see this record in my datagrid1
i want to write a code to update my datagrid, dataset !!!!
i wrote this code but it's not a good solution to refill datagrid1, coz datagtid1 is showing
the records from the beginning , not from where i deleted the record but the scroll bar location is where i deleted the record !!!!!!
string MyConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ALOHA_PATH + "\\stockcontrol;Extended Properties=dBase IV";
OleDbConnection MyOleb = new OleDbConnection(MyConnection);
OleDbDataAdapter da= new OleDbDataAdapter("Select * from STOCK.dbf",MyOleb);
DataSet dsrefresh = new DataSet();
da.Fill (dsrefresh,"Stock");
dataGrid1.DataSource = dsrefresh.DefaultViewManager;
dataGrid1.ReadOnly = true;
MyOleb.Close();
Thx
|
|
|
|
|
I noticed that my HOOK function isn't capturing mouse related messages. But others like WM_ACTIVEAPP is fine. I'm using the CallWndProc method instead of a mouse hook procedure.
I want to be able to peek at ALL mouse and keyboard related windows messages across the desktop and other applications. The mouse hook seemed to only capture what was being delivered to my app. When i was experimenting with the mouse hook proc, i did this:
hHook = SetWindowsHookEx(WH_MOUSE,MouseHookProcedure,
(IntPtr)0,0);
.. to specify all threads across the desktop (last param). But it crashed here. Doesn't like the last two parameters 0 and 0. So this is why i'm not trying CallWndProc.
Any ideas of how to do this?
private void button8_Click(object sender, System.EventArgs e)
{
if(hHook == 0)
{
CWPHookProcedure = new HookProcDT(Form1.CWPHookProc);
hHook = SetWindowsHookEx
(WH_CALLWNDPROC,
CWPHookProcedure,
IntPtr.Zero,
User32.GetWindowThreadProcessId(this.Handle.ToInt32(),
0));
.. etc
.. and then in my CallWndProc hook method:
public static int CWPHookProc(int code, IntPtr wparam, IntPtr lParam)
{
if (code < 0)
return User32.CallNextHookEx(hHook, code, wparam, lParam);
CWPSTRUCT cwp = (CWPSTRUCT) Marshal.PtrToStructure(
lParam,
typeof(CWPSTRUCT));
if (code == 0) //this means that the hook procedure should process the
//message contained in CWPSTRUCT
{
switch(cwp.message)
{
case WM_ACTIVATEAPP: //GET'S HERE
MessageBox.Show("Is here in CWPHookProc");
break;
case WM_MOUSEMOVE: //BUT NOT HERE
MessageBox.Show("Is here in CWPHookProc");
break;
}
}
return User32.CallNextHookEx(hHook, code, wparam, lParam);
}
//Declare wrapper managed CWPStruct class.
[StructLayout(LayoutKind.Sequential)]
public class CWPSTRUCT
{
public IntPtr lparam;
public IntPtr wparam;
public int message;
public IntPtr hwnd;
}
|
|
|
|
|
c121hains wrote:
I want to be able to peek at ALL mouse and keyboard related windows messages across the desktop and other applications.
What you need are global hooks. Fortunately there are WH_MOUSE_LL[^] and WH_KEYBOARD_LL[^] which don't use code injection and can be used with managed code. Check out Processing Global Mouse and Keyboard Hooks in C#[^] to get a working code example.
Best regards
Dennis
|
|
|
|
|
This worked great! Thank you!
|
|
|
|
|
|
how to edit,insert,update database on datagrid same on microsoft excel
koochinh
|
|
|
|
|
Hi,
I was wondering if there is a better method to check that a string is a number. I have a text box and the user must type a number, to check that is what I have I attempt to parse it like this:
int result = int.MinValue;
try
{
result = int.Parse(someTextBox.Text);
}
catch(Exception ex)
{
// Not a number, do error processing
}
I don't like the idea of throwing an exception when I know users will do dumb things. Is there a better way than this?
Cheers,
Andy.
|
|
|
|
|
|
Have a look at Double.TryPass .
Hope this helps
Tom
|
|
|
|
|
Hi,
I am trying to find the total system memory usage using the PerformanceCounter class:
PerformanceCounter memoryCounter = new PerformanceCounter("Memory", CounterName);
The PerformanceCounterCategory named "Memory" contains the following PerformanceCounters:
- Page Faults/sec
- Available Bytes
- Committed Bytes
- Commit Limit
- Write Copies/sec
- Transition Faults/sec
- Cache Faults/sec
- Demand Zero Faults/sec
- Pages/sec
- Pages Input/sec
- Page Reads/sec
- Pages Output/sec
- Pool Paged Bytes
- Pool Nonpaged Bytes
- Page Writes/sec
- Pool Paged Allocs
- Pool Nonpaged Allocs
- Free System Page Table Entries
- Cache Bytes
- Cache Bytes Peak
- Pool Paged Resident Bytes
- System Code Total Bytes
- System Code Resident Bytes
- System Driver Total Bytes
- System Driver Resident Bytes
- System Cache Resident Bytes
- % Committed Bytes In Use
- Available KBytes
- Available MBytes
Which PerformanceCounter would best accomplish this?
Thanks,
Alex
Intern
MSN Music Testing
Microsoft
|
|
|
|
|
Does anyone know which counter i would need to use?
Intern
MSN Music Testing
Microsoft
|
|
|
|
|
|
I need to localize the dateTimepicket to view the current date in arabic.. I i need for example 9 July 2004 to display 9 July 2004 but in arabic characters
|
|
|
|
|
why when I design everything in design time (IDE) including the size and location, then when i run the program everything looks different!!!
the size, location, etc is totally changed!!!
please help...
|
|
|
|
|
Have u put the DefaultValue attribute on your properties?
[DefaultValue(false)]
public int SomeProperty
{
get{...}
set{...}
}
|
|
|
|
|
no, i didn't..
what i mean in my question is:
when I place controls on my form in IDE at deisgn time and arrange it very nicely and then I run the program I find that the whole thing changes!! the form size will change.. controls sizes will change.. controls positions will change...
for you information, I am using a localized form with righ-to-left..
|
|
|
|
|
I am building an application in which I want to generate varialble amount of buttons on a windows form dynamically in run time...But since the size of the windows form is limited,I would like to use a scroll bar but I don't know how I can use it ..Can anyone help me please?
Best Regards,
E6AD
|
|
|
|
|
It should be sufficient to assign true to the Form.AutoScroll property. If this property is set to true, scroll bars are displayed on the form if any controls are located outside the form's client region. Additionally, when autoscrolling is on, the client area of the form automatically scrolls to make the control with input focus visible.
www.troschuetz.de
|
|
|
|
|
I am trying to populate a treeView with the folders of my logical drives (this includes subfolders) so that it's almost like the format of Windows Explorer. I have checked various forums and MSDN, but that help is aimed more for advanced users. Does anyone know how to do this or a thread of how to do this?
Thanks!!
|
|
|
|
|
It would help if you told us what exactly are you having problems with...
The process itself is fairly straightforward, if you know how to use recursion.
You create a function where you have a directory and a TreeNode as parameter, let's say
void AddDirectoryNodes(TreeNode parent, string path)
In this function you get yourself a list of all subdirectories of path (the Directory class has a method for this).
For each subdirectory you create a new TreeNode (with the subdirectory's name as node name) and add it to parent 's Nodes collection.
Then you call AddDirectoryNodes() from within itself with the newly added TreeNode as parent and the current subdirectory as path .
Voila, you get a nice tree structure of all directories.
Then all that remains is to enumerate all your drives, add a TreeNode for each drive and then call AddDirectoryNodes for these drive nodes.
Did this description help?
mav
|
|
|
|
|
Your pseudocode aided me in getting the final solution. THANK YOU!!
Here's the code for displaying all folders in your computer's logical drives in the windows explorer-style (assuming you have a hard drive C:\ and D:\:
string[] logical_drives = System.IO.Directory.GetLogicalDrives();
foreach(String drive_letter in logical_drives)
{
if(drive_letter.Equals("C:\\") || drive_letter.Equals("D:\\"))
{
TreeNode root_node = new TreeNode(drive_letter);
treeView1.Nodes.Add(root_node);
populateTreeView(drive_letter, root_node);
}
}
private void populateTreeView(string directory_name, TreeNode parent_node)
{
DirectoryInfo dir_info = new DirectoryInfo(directory_name);
DirectoryInfo[] directory_array = dir_info.GetDirectories();
foreach(DirectoryInfo current_directory in directory_array)
{
TreeNode new_node = new TreeNode(current_directory.Name);
parent_node.Nodes.Add(new_node);
if(current_directory.GetDirectories() != null)
populateTreeView(current_directory.FullName, new_node);
}
}
Now that I have the treeview filled with all the folders in my drives, I need to do 1 more thing. When I select a node, I write the full path of the node to a text file to save the path. When I reopen the application, I would like to have the same folder selected so I can resume my work in that folder. This is the code I would like to have, but it doesn't work:
StreamReader sr = new StreamReader("directory.txt");
if((line = sr.ReadLine()) != null && line != "")
{
treeView1.SelectedNode.FullPath = line;
sr.Close();
}
How can I select a given node at form load time?
|
|
|
|
|
Hi all,
I'm developing a custom DataGrid Column, that hosts a custom IPAddress Control.
I Should override the Paint mathod to paint the desiered text on the GridColumn
when the Paint method is called because the DataGrid USer clicks the last row in the grid to insert a new value.
i retrieve the value from the Column using "GetColumnValueAtRow ( source,rowNum )" and Paint it as shown in the code below.
i handled the problem of retrieving an invalid value but assign the NullText property that i previosly set.
But still the Paint draws 4 extra empty rows instead of only one.
anyway seems that i'm not handling the Paint method properly so does anyone knows how i should handle the Paint method when the User clicks on the last row in the DataGrid to insert a new value.
protected override void Paint
(
Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum,
Brush backBrush,
Brush foreBrush,
bool alignToRight
)
{
try
{
string strIPAddress = "" ;
try
{
strIPAddress = ( string ) GetColumnValueAtRow ( source,
rowNum ) ;
}
catch
{
strIPAddress = this.NullText ;
}
Rectangle rect = bounds ;
g.FillRectangle ( backBrush,rect ) ;
rect.Offset ( 0, 2 ) ;
rect.Height -= 2 ;
g.DrawString ( strIPAddress ,
this.DataGridTableStyle.DataGrid.Font,
foreBrush,
rect ) ;
}
catch
{
System.Diagnostics.Debug.Assert ( false ) ;
}
}
|
|
|
|
|
when creating a windows service, I wanted to change the ServiceName property - in which IDE Properties window can I find the ServiceName property and change it to whatever name I want??
|
|
|
|
|
From the MSDN documentation.
The ServiceName identifies the service to the Service Control Manager. The value of this property must be identical to the name recorded for the service in the ServiceInstaller.ServiceName property of the corresponding installer class. In code, the ServiceName of the service is usually set in the main() function of the executable.
There isn't IDE support, you have to write code to set that value.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|