|
If it has an Invalidate method, call it, that forces a repaint of a control.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
But DataGridViewImageCell does not have a Invalidate method.
|
|
|
|
|
Then you probably need to Invalidate the entire grid.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
There is a method grid.InvalidateCell however I cannot call it because I have to do it from DataGridViewImageCell level (form my own class). I described the problem above.
Thanks for advice.
|
|
|
|
|
I migrated one of my solutions to .net 2005 from 2003.
Issues:
When I am going to rebuile it some of the reerances are deleted from the dubug folder of some projects and compilation error comes saying that referance not found.
But if I am building (Not Rebuild) each projects differantly then this problem is not coming
Whatshould I do?
Please help me.
Rabindra Patra
|
|
|
|
|
Delete all the references and add them again.
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
In C#, how should I use a VB ocx that is dependent on a win32 dll ?
When ActiveX is dependent on another dll should we do something different?
|
|
|
|
|
TinyTin wrote: ocx
Hit the nail on the head here, an OCX is an OCX, doesn't matter whether it's VB, C++, Python, PHP, C#, VB.NET
TinyTin wrote: When ActiveX is dependent on another dll should we do something different?
No, just make sure the dependency is there when you try an access it.
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
Hi all,
i need to write some program to handle registry please give me some links or some guidence to do something . this type of programming is new for me so plz guide in detail.
thanks in advance.
Keep Praying
|
|
|
|
|
This piece of code helped me alot, hope it'll work for you.
/* ***************************************
* ModifyRegistry.cs
* ---------------------------------------
* a very simple class
* to read, write, delete and count
* registry values with C#
* ---------------------------------------
* if you improve this code
* please email me your improvement!
* ---------------------------------------
* by Francesco Natali
* - fn.varie@libero.it -
* ***************************************/
using System;
// it's required for reading/writing into the registry:
using Microsoft.Win32;
// and for the MessageBox function:
using System.Windows.Forms;
namespace Utility.ModifyRegistry
{
/// <summary>
/// An useful class to read/write/delete/count registry keys
/// </summary>
public class ModifyRegistry
{
private bool showError = false;
/// <summary>
/// A property to show or hide error messages
/// (default = false)
/// </summary>
public bool ShowError
{
get { return showError; }
set { showError = value; }
}
private string subKey = "SOFTWARE\\" + Application.ProductName.ToUpper();
/// <summary>
/// A property to set the SubKey value
/// (default = "SOFTWARE\\" + Application.ProductName.ToUpper())
/// </summary>
public string SubKey
{
get { return subKey; }
set { subKey = value; }
}
private RegistryKey baseRegistryKey = Registry.LocalMachine;
/// <summary>
/// A property to set the BaseRegistryKey value.
/// (default = Registry.LocalMachine)
/// </summary>
public RegistryKey BaseRegistryKey
{
get { return baseRegistryKey; }
set { baseRegistryKey = value; }
}
/* **************************************************************************
* **************************************************************************/
/// <summary>
/// To read a registry key.
/// input: KeyName (string)
/// output: value (string)
/// </summary>
public string Read(string KeyName)
{
// Opening the registry key
RegistryKey rk = baseRegistryKey ;
// Open a subKey as read-only
RegistryKey sk1 = rk.OpenSubKey(subKey);
// If the RegistrySubKey doesn't exist -> (null)
if ( sk1 == null )
{
return null;
}
else
{
try
{
// If the RegistryKey exists I get its value
// or null is returned.
return (string)sk1.GetValue(KeyName.ToUpper());
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Reading registry " + KeyName.ToUpper());
return null;
}
}
}
/* **************************************************************************
* **************************************************************************/
/// <summary>
/// To write into a registry key.
/// input: KeyName (string) , Value (object)
/// output: true or false
/// </summary>
public bool Write(string KeyName, object Value)
{
try
{
// Setting
RegistryKey rk = baseRegistryKey ;
// I have to use CreateSubKey
// (create or open it if already exits),
// 'cause OpenSubKey open a subKey as read-only
RegistryKey sk1 = rk.CreateSubKey(subKey);
// Save the value
sk1.SetValue(KeyName.ToUpper(), Value);
return true;
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Writing registry " + KeyName.ToUpper());
return false;
}
}
/* **************************************************************************
* **************************************************************************/
/// <summary>
/// To delete a registry key.
/// input: KeyName (string)
/// output: true or false
/// </summary>
public bool DeleteKey(string KeyName)
{
try
{
// Setting
RegistryKey rk = baseRegistryKey ;
RegistryKey sk1 = rk.CreateSubKey(subKey);
// If the RegistrySubKey doesn't exists -> (true)
if ( sk1 == null )
return true;
else
sk1.DeleteValue(KeyName);
return true;
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Deleting SubKey " + subKey);
return false;
}
}
/* **************************************************************************
* **************************************************************************/
/// <summary>
/// To delete a sub key and any child.
/// input: void
/// output: true or false
/// </summary>
public bool DeleteSubKeyTree()
{
try
{
// Setting
RegistryKey rk = baseRegistryKey ;
RegistryKey sk1 = rk.OpenSubKey(subKey);
// If the RegistryKey exists, I delete it
if ( sk1 != null )
rk.DeleteSubKeyTree(subKey);
return true;
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Deleting SubKey " + subKey);
return false;
}
}
/* **************************************************************************
* **************************************************************************/
/// <summary>
/// Retrive the count of subkeys at the current key.
/// input: void
/// output: number of subkeys
/// </summary>
public int SubKeyCount()
{
try
{
// Setting
RegistryKey rk = baseRegistryKey ;
RegistryKey sk1 = rk.OpenSubKey(subKey);
// If the RegistryKey exists...
if ( sk1 != null )
return sk1.SubKeyCount;
else
return 0;
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Retriving subkeys of " + subKey);
return 0;
}
}
/* **************************************************************************
* **************************************************************************/
/// <summary>
/// Retrive the count of values in the key.
/// input: void
/// output: number of keys
/// </summary>
public int ValueCount()
{
try
{
// Setting
RegistryKey rk = baseRegistryKey ;
RegistryKey sk1 = rk.OpenSubKey(subKey);
// If the RegistryKey exists...
if ( sk1 != null )
return sk1.ValueCount;
else
return 0;
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Retriving keys of " + subKey);
return 0;
}
}
/* **************************************************************************
* **************************************************************************/
private void ShowErrorMessage(Exception e, string Title)
{
if (showError == true)
MessageBox.Show(e.Message,
Title
,MessageBoxButtons.OK
,MessageBoxIcon.Error);
}
}
}
He who laughs last is a bit on the slow side
|
|
|
|
|
Hi,
Dear Respected Programmers
Kindly check the following command that, How may I make it correct? because i am getting an error => "culture name 'en-uk' is not supported"
Command is:
-----------
Application.CurrentCulture = new System.Globalization.CultureInfo("en-UK");
Thank you very much
|
|
|
|
|
Hi,
Try something like:
<br />
Application.CurrentCulture = new System.Globalization.CultureInfo("en-GB");<br />
Do your best to be the best
|
|
|
|
|
How to extend DataGrid so that i can add a property to its column?
|
|
|
|
|
Hello,
I have a problem with a dynamically allocated datagrid whose horizontol scroll bar does not scroll as expected when using the arrow keys. It is jittery but most irritatingly it stops about 50 pixels from scrolling full right.
Can anyone please help?
Kiterq...
|
|
|
|
|
[data]
string sbStrings = @"program files\software\program\report.htm,8/10/2006 4:23 pm-program files\software\program\report.htm,8/10/2006 2:25 pm-program files\software\program\report.htm,6/23/2006 8:14 pm-program files\software\program\report.htm,8/30/2006 1:12 pm";
Q. How would I split this , and - delimited string into a string [,] array?
or use something like this:
ArrayList list = new ArrayList();
list.Add(new ArrayList());
string1 string2
program files\softsoftware\program\help\help3.htm 9/22/2006 2:22 pm
|
|
|
|
|
kvnsdr wrote: Q. How would I split this , and - delimited string into a string [,] array?
<FONT color=Blue>public</FONT> <FONT color=Blue>static</FONT> <FONT color=Blue>string</FONT><FONT color=DarkBlue>[]</FONT> Tokenize<FONT color=DarkBlue>(</FONT><FONT color=Blue>string</FONT> name<FONT color=DarkBlue>,</FONT> <FONT color=Blue>params</FONT> <FONT color=Blue>string</FONT><FONT color=DarkBlue>[]</FONT> delimiters<FONT color=DarkBlue>)</FONT>
<FONT color=DarkBlue>{</FONT>
<FONT color=Blue>for</FONT> <FONT color=DarkBlue>(</FONT><FONT color=Blue>int</FONT> i <FONT color=DarkBlue>=</FONT> <FONT color=Red>0</FONT><FONT color=DarkBlue>;</FONT> i <FONT color=DarkBlue><</FONT> delimiters<FONT color=DarkBlue>.</FONT><FONT color=Teal>Length</FONT><FONT color=DarkBlue>;</FONT> i<FONT color=DarkBlue>++</FONT><FONT color=DarkBlue>)</FONT>
<FONT color=DarkBlue>{</FONT>
delimiters<FONT color=DarkBlue>[</FONT><FONT color=Teal>i</FONT><FONT color=DarkBlue>]</FONT> <FONT color=DarkBlue>=</FONT> Regex<FONT color=DarkBlue>.</FONT>Escape<FONT color=DarkBlue>(</FONT>delimiters<FONT color=DarkBlue>[</FONT><FONT color=Teal>i</FONT><FONT color=DarkBlue>]</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=DarkBlue>}</FONT>
<FONT color=Blue>string</FONT> del <FONT color=DarkBlue>=</FONT> <FONT color=Blue>string</FONT><FONT color=DarkBlue>.</FONT>Join<FONT color=DarkBlue>(</FONT><FONT color=Maroon>"|"</FONT><FONT color=DarkBlue>,</FONT> delimiters<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=Teal>Regex</FONT> re <FONT color=DarkBlue>=</FONT> <FONT color=Blue>new</FONT> <FONT color=Teal>Regex</FONT><FONT color=DarkBlue>(</FONT>del<FONT color=DarkBlue>,</FONT> RegexOptions<FONT color=DarkBlue>.</FONT>Compiled<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
List<FONT color=DarkBlue><</FONT><FONT color=Blue>string</FONT><FONT color=DarkBlue>></FONT> tokens <FONT color=DarkBlue>=</FONT> <FONT color=Blue>new</FONT> <FONT color=Teal>List</FONT><FONT color=DarkBlue><</FONT><FONT color=Blue>string</FONT><FONT color=DarkBlue>></FONT><FONT color=DarkBlue>(</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=Blue>int</FONT> lastend <FONT color=DarkBlue>=</FONT> <FONT color=Red>0</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=Blue>foreach</FONT> <FONT color=DarkBlue>(</FONT><FONT color=Teal>Match</FONT> m <FONT color=Blue>in</FONT> re<FONT color=DarkBlue>.</FONT>Matches<FONT color=DarkBlue>(</FONT>name<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>)</FONT>
<FONT color=DarkBlue>{</FONT>
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>m<FONT color=DarkBlue>.</FONT>Index <FONT color=DarkBlue>></FONT> lastend<FONT color=DarkBlue>)</FONT>
<FONT color=DarkBlue>{</FONT>
tokens<FONT color=DarkBlue>.</FONT>Add<FONT color=DarkBlue>(</FONT>name<FONT color=DarkBlue>.</FONT>Substring<FONT color=DarkBlue>(</FONT>lastend<FONT color=DarkBlue>,</FONT> m<FONT color=DarkBlue>.</FONT>Index <FONT color=DarkBlue>-</FONT> lastend<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=DarkBlue>}</FONT>
tokens<FONT color=DarkBlue>.</FONT>Add<FONT color=DarkBlue>(</FONT>m<FONT color=DarkBlue>.</FONT>Value<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
lastend <FONT color=DarkBlue>=</FONT> m<FONT color=DarkBlue>.</FONT>Index <FONT color=DarkBlue>+</FONT> m<FONT color=DarkBlue>.</FONT>Length<FONT color=DarkBlue>;</FONT>
<FONT color=DarkBlue>}</FONT>
tokens<FONT color=DarkBlue>.</FONT>Add<FONT color=DarkBlue>(</FONT>name<FONT color=DarkBlue>.</FONT>Substring<FONT color=DarkBlue>(</FONT>lastend<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=Blue>return</FONT> tokens<FONT color=DarkBlue>.</FONT>ToArray<FONT color=DarkBlue>(</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=DarkBlue>}</FONT>
|
|
|
|
|
Hello everybody.
I'm actually working on a service for phone call notification... However, to achieve that I downloaded a library called CapiThread (this is a sort of wrapper for the capi2032.dll). This is an "old" Win32 dll that exports 5 methods. (InitCapiThread, CloseCapiThread, RegisterNotifyMessage, SetRequest, GetIndication).
To use that dll within a C# Windows-Service project i've written a COM wrapper (COM Object ISDNCapi). The ISDNCapi object retrieves the notifications thrown by the CapiThread dll if an indication is pending and fires an event (OnCapiIndication). There are some other classes to hold the data of the indications and requests.
Okay...
Now i've build a metadata-dll with TLBIMP that i use in my program. (As descripted in "COM Interoperability in .NET Framework: Part I"). The code compiles without any problems, but during the instantiation of my class ISDNCapi the following error raises:
Retrieving the COM class factory for component with CLSID {3A5119AE-E5CC-406F-8F62-FFC340C424CE} failed due to the following error: 80040154.
The component is definetly registered and can access it's dependecies, because instantiation it in VB6 causes no error and the regsvr32 succeeds also.
So what i'm doing wrong?
(While writing this article i'd an idea: I'm using WinXP x64 platform. Could that be the cause of the error? - But i'm definetly compiling for Win32)
I've uploaded the sources of my projects to my server:
CapiWrapperSln
ISDNMonServer
And here are the complete exception details:
System.Runtime.InteropServices.COMException was unhandled<br />
Message="Retrieving the COM class factory for component with CLSID {3A5119AE-E5CC-406F-8F62-FFC340C424CE} failed due to the following error: 80040154."<br />
Source="ISDNMonServer"<br />
ErrorCode=-2147221164<br />
StackTrace:<br />
at ISDNMonServer.ISDNMonServer..ctor() in E:\Entwicklungsumgebung\Projekte\Office\ISDNMon\ISDNMonServer\ISDNMonServer.cs:line 20<br />
at ISDNMonServer.Program.Main() in E:\Entwicklungsumgebung\Projekte\Office\ISDNMon\ISDNMonServer\Program.cs:line 22<br />
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)<br />
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br />
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
at System.Threading.ThreadHelper.ThreadStart()<br />
thanks.
Martin.
|
|
|
|
|
Hi!
The error 0x80040154 means "Class not registered".
Your component itself may be registered, but the error states that the Class Factory (!) could not be retrieved because it's not registered.
Could it be that your COM wrapper is missing this point?
Btw. why do you need the COM wrapper? You can call functions from "legacy" Win32 dlls using P/invoke without having to use a COM wrapper...
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
i thougt i'd already answered... hm, maybe i forgot to post it
i've created the project with the option "component registrar". do i have to call the RegisterAll function of the Registrar class?
in vc 6 i never had to register the class factory separately... so i don't really know what to look for :-> . can you please check it in my sourcecode i've posted before?
i know that i can youse P/invoke. but i've choosen to build a com wrapper, because i want to have a more general solution. so i can use it with other languages... and i found the event handlers better than hooking on notify messages (in C#) the CapiThread.dll sends.
thx.
Martin
|
|
|
|
|
Hi Everybody !
in btnShow_Click() :
try<br />
{<br />
string query="Select * from TestReport";<br />
con.Open();<br />
da=new SqlDataAdapter(query,con);<br />
sqlcmb=new SqlCommandBuilder(da);<br />
da.Fill(DS,"TestReport");<br />
dt = DS.Tables["TestReport"];<br />
dv = dt.DefaultView;<br />
dataGrid1.DataSource=dv;<br />
con.Close();<br />
sqlcmb.Dispose();<br />
con.Dispose();<br />
}<br />
catch(Exception ex)<br />
{ <br />
MessageBox.Show(ex.ToString());<br />
}<br />
}
at the first I have no problem for showing records , but at the second when I press th Show Button , I have this error :
The ConnectionString property has not been initialized !
thanx for any help !
Regards ,
s_mostafa_h
|
|
|
|
|
Hello
Your problem is in this line:
con.Dispose();
You shouldn't dispose the connection if you'll use it again. also I don't recommend opening/closing the connection each time you make a query.
Regards
|
|
|
|
|
hi there ,
but , if it does'nt Dispose() , eachtime , I press the button , all previous records is added again to the end of record .
thanx a lot ,
s_mostafa_h
|
|
|
|
|
Try clearing your data objects explicitly rather than disposing the connection.
|
|
|
|
|
connection(con) has not any property for "Clear()" , Ccan u more explain , plz?;)
s_mostafa_h
|
|
|
|
|
Hello
You shouldn't dispose your connection until you don't need it anymore in the current session. If you want to clear you DataGridView -as I understood from your reply-, then you should call the DataGridView.Rows.Clear() method before filling it again.
Regards
|
|
|
|