|
Hello there!
I am currently writing a chat-program. All of the network functions are (almost) working properly. But i have one problem though. I want the richTextBox to autoscroll when the text goes behind the border of the control (like Windows Messenger)
I hope that you can help me with this!
Regards
|
|
|
|
|
richTextBox1.Focus();
richTextBox1.SelectionStart=richTextBox1.TextLength;
richTextBox1.ScrollToCaret();
Darryl Borden
Principal IT Analyst
dborden@eprod.com
|
|
|
|
|
Thanks a lot!!
I tried something similar, but it didn't work..
Thanks Again!
Regards
|
|
|
|
|
I'm using odbc to call stored procedures in a way similar to the small amount of sample code below:
OdbcCommand command = conn.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "call proc(?, ?, ?, ?, ?, ?, ?, ?, ?)";
OdbcParameter param = new OdbcParameter("paraName", OdbcType.VarChar, 4);
param.Direction = ParameterDirection.Input;
command.Parameters.Add(param);
command.ExecuteNonQuery();
...and then accessing them like this:
command.Parameters["paraName"].Value;
This has been working great; except now I have encountered a situation where the stored procedure is attempting to return an entire table (instead of a single record) as one of its output parameters. How do I handle this? Is there a special Odbctype that I should be using? And then, how I access each record within the table once it has been retrieved?
Thanks!
|
|
|
|
|
Hello,
Here's what I'd like to do:
I have a byte[]. This could contain anything. I want to search it and replace every instance of "OldText" with "NewText". I'm actually trying to expand a token. So if I find the token, I want to replace it with the expanded value. Here's what I'm trying to do (pseudo-code)
------------------------------------------------------------------------
string Token = "%SomeToken%";
string Value = "ExpandedToken";
byte[] Data = GetRegBinary(); // Data contains some REG_BINARY data
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
// Convert the OldText to Base64String
byte[] buf1 = enc.GetBytes(Token);
string OldText = Convert.ToBase64String(buf1);
// Convert the NewText to Base64String
byte[] buf2 = enc.GetBytes(Value);
string NewText = Convert.ToBase64String(buf2);
// Convert the target data to Base64String
string TargetData = Convert.ToBase64String(Data);
// Now replace the OldData with the NewData in the TargetData
TargetData = TargetData.Replace(OldData, NewData);
// Convert the TargetData back to Byte[]
Data = Convert.FromBase64String(TargetData);
------------------------------------------------------------------------
I was hoping I could use some built-in encoding so I wouldn't have to write my own. This seems like a good logical approach but it's not working (I don't know why) and I'm getting the feeling that I'm using the wrong tool for the job...
Any ideas?
Thanks!
-Ian
|
|
|
|
|
What about something like the following:
ASCIIEncoding ae = new ASCIIEncoding();
byte[] bInput = ae.GetBytes("Hello Nick");
string sConversion = ae.GetString(bInput);
string sOutput = sConversion.Replace("Nick", "World");
byte[] bOutput = ae.GetBytes(sOutput);
|
|
|
|
|
Beautiful! Thank you!
-Ian
|
|
|
|
|
Is there a way to login to the Yahoo network using a Credentials object and then retrieve pages based on those credentials?
For example, I want to write something that will automatically check for and inform me if I have any email messages.
Thanks for any help.
|
|
|
|
|
I have a datagrid with one long colunm binding from a dataset. Is there a way to break it to multiple colunm to make it look better. Thanks
|
|
|
|
|
try to make this column not DataColumn but DataGridTextBoxColumn in the DataGridTableStyle and then after setting :
<br />
DataGridTextBoxColumn col = new DataGridTextBoxColumn();<br />
col.MappingName = "youColumnName";<br />
col.TextBox.MultiLine = true;<br />
col.Width = theWidthYouWant;<br />
DataGridTableStyle styl = new DataGridTableStyle();<br />
styl.MappingName = yourDataSet.yourTableName;<br />
style.GridColumnStyles.Add(col);<br />
dataGrid1.TableStyles.Add(styl);<br />
and there is a very good thing that you won't apply it to each row ,by default it's applied to all the columns in all the rows in this datagrid
|
|
|
|
|
Hello!
I'm starting to develop in C# for pocket pc's...
Can anyone tell me a good place to get some examples on the small device C# api?
Thanks a lot!
b4silence - Portugal
|
|
|
|
|
All,
I am writing a program that looks at a registry entry and based on the type of data at a particular key, performs different operations. So, given a RegistryKey item opened to a specific key, how do I determine the type of data stored there? Is there a way I can compare the key type against a REG_SZ or REG_DWORD? I looked at the GetType function but that seems to return a generic Microsoft.Win32.RegistryKey type based on the open key.
Any help would be greatly appreciated.
Regards,
Brigg Thorp
Senior Software Engineer
Timex Corporation
|
|
|
|
|
If you get a registry value that is REG_SZ, the GetType() method will return System.String. For REG_DWORD values it returns System.Int32. For REG_BINARY values it returns System.Byte[]. You can compare against these values. You might be able to use the "is" keyword as follows:
if(myRegValue is System.String)...
If that doesn't work (it's been a while since I've needed to do this) you can always fall back on a string compare:
if(myRegValue.GetType().ToString() == "System.String")...
I think the first way should work though...
Hope that helps.
Regards,
Ian
|
|
|
|
|
Worked perfectly! Thanks
Brigg Thorp
Senior Software Engineer
Timex Corporation
|
|
|
|
|
The Registry class doesn't expose any kind of method to determine the exact registry type that is stored. The class was written to insulate you from having to worry about those kind of details. IMHO, it also made the
Registry utterly useless.<br />
<br />
In order to get this functionality, you'll have to write your own code to P/Invoke the Win32 API Registry functions to enumerate the Values in a specified Key (RegOpenKeyEx, RegEnumValue), then call the RegQueryValueEx functionto return the Type and Data associated with the Value names returned by RegEnumValue.<br />
<br />
No, I don't have any example code for it. Try Google for a more comprehensive Registry class.<br />
<br />
<br />
<br />
RageInTheMachine9532<font size="-1"><br />
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome</font>
|
|
|
|
|
Check out Ian's approach above. It actually works very well for my needs.
Regards,
Brigg Thorp
Senior Software Engineer
Timex Corporation
|
|
|
|
|
Like system files and stuff, when you try to delete them, it says that it cant.
I want to know if i can protect a file in some way from deletion, i only want something simple, so if its to complicated dont bother, (or direct me to an article or something, maybe i'll look at it).
And no im not making a virus (that would be mean), its for a file encryption thing, and i dont want people to be deleting files that they cant access
|
|
|
|
|
The Undefeated wrote:
and i dont want people to be deleting files that they cant access
If they can't access the file, they can't delete it.
The only sure fire way to stop this from happening is to set the appropriate NTFS Permissions on the file. You CANNOT stop anyone from deleteing a file through the use of code. Unless, of course, you write a file system extension, which is not for the faint of heart or weak of COM Interop skills!
What are you really doing? What's the real goal and what is your project about?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The reason that some of the system files prevent you from deleting them is because they are in use. But I hardly think creating a dummy application that holds a file open to prevent it from being deleted is appropriate. If you don't want it deleted then change file permissions, or keep a 'cache' directory that will replace the file if it notices it is missing. This is something Windows XP does.
-
Drew
|
|
|
|
|
Hi,
I created an ATL COM object which i want to use from C#. I'm generating events from the ATL COM that's caught on the C# end.
<br />
[id(1), helpstring("method MyEvent")] HRESULT MyEvent([in,out] int* message);<br />
<br />
private static void MyEvent(ref int message)<br />
{<br />
Console.Writeline("Got Event");<br />
}<br />
<br />
The problem is that the int* in the method is automatically marshalled to a ref int on the c# side. I want it to be marshalled to a IntPtr. So i decompiled the Interop.MyProject.dll and changed all the int32& in the necessary methods to native int.
.method public virtual instance void MailEvent(int32& A_1) cil managed
Becomes
.method public virtual instance void MailEvent(native int A_1) cil managed
Now i can use private static void MyEvent(IntPtr message) to catch the event.
But now the "Got Event" doesn't get printed out.
The event doesn't get caught.
Does anyone know why this shouldnt work?
BTW. I want to use an IntPtr so that i can send this structure through to the C# side.
c++
<br />
typedef struct Message<br />
{<br />
BSTR subject;<br />
....<br />
....<br />
} Message;<br />
<br />
Message *msg = new Message();<br />
MyEvent((int*)msg);<br />
c#
<br />
[StructLayoutAttribute(LayoutKind.Sequential)] <br />
public struct Message<br />
{<br />
public string subject; <br />
}<br />
<br />
private static void MyEvent(IntPtr message)<br />
{<br />
Message msg = new Message();<br />
Marshal.PtrToStructure(message,msg);<br />
}<br />
|
|
|
|
|
Hi,
Could anyone please guide me how it is possible to make an instance of
a child form from a class file.assume I have a class named whichForm.cs,
a Mainform named frmMain and some MdiChildForms( frmImp,frmExp,....)
I am in need of making instance of MdiChildForms within the WhichForm.cs class and show() them in their parent form (frmMain), something like:
WhichForm.cs
public class WhichForm
{
.....
.....
frmImp FI=new frmImp();
FI.MdiParent=frmMain;
FI.Show();
}
but the problem is that the new MdiChildForm should be declare once in
the frmMain form and called within the class.
Could somebody point me in the right direction to get this working?
Thanks,
M.Jafarpour
|
|
|
|
|
Greetings:
I am reduced to grovelling for help. This has been going on for days...
I have MSDE installed on my laptop. When I click the Service Manager, it says that the name of my server is "JIM-MOBILE" that's the name of my laptop when connected to the server here at work, so, I'll buy that.
I am trying to carry out an example from a Wrox book on C#. It forms a source for a connection string as follows:
string source = "data source=NorthWin;initial catalog=Northwind;integrated security=SSPI;"
In another example he uses:
source = "server=;uid=<id>;pwd=<pw>;database=Northwind";
It then attempts to create a connection and open the connection:
SqlConnection conn = new SqlConnection(source);
conn.Open();
It always hangs for about 15 seconds and then issues an exception with unintelligable information that is of no help to me.
The only Northwind database I have is from an installation of Access. I have placed a copy in a directory called "C:\JimData\".
I cannot figure out how to create this data source so that this connection attempt succeeds. Each time I venture into the ODBC Data Sources panel, I am stupified by the options and inputs. I have tinkered around with it on and off for DAYS. I have scoured the internet's programmer forums and knowledge bases. I am sinking into abject dispare...
Thank you in advance to anyone who tries to help.
Jethro63
|
|
|
|
|
Your two examples are trying to connect to the Northwind database in SQL Server.
You are trying to connect to the Northwind database (the data and structure) but on Access. You need a different connection string (see here[^]) and to use the OleDb * classes (OleDbConnection and OleDbCommand for example), since the Sql * classes are only for SQL Server.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi LuiSR:
Image that? An entire WEB site dedicated to connection strings for databases...
Thank you! It worked.
Was I mistaken to think that I could connect to a database created with Access using SQL Server? Many of the examples that I have encountered specifically name the Northwind example and specifically use SQL Server - including the one from this Wrox book I've been reading.
Thank you again,
Jethro63
|
|
|
|
|
Jethro63 wrote:
Was I mistaken to think that I could connect to a database created with Access using SQL Server?
No you can't. They are two VERY different animals. Access doesn't support stored procedures in the sense that a normal SQL database does. You can't write entire procedures or batches of statements in Access/Jet. It only supports single statement per "stored procedure".
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|