|
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
|
|
|
|
|
Jethro63 wrote:
An entire WEB site dedicated to connection strings for databases
Things you can find on the web...
Jethro63 wrote:
Was I mistaken to think that I could connect to a database created with Access using SQL Server?
To add and clarify what Dave replied, a database by itself is only the collection of tables with some data. SQL Server and Access are two database applications, as are many others like mysql, Oracle, and so on. So, you can have your collection of tables (the Northwind database) in an SQL Server database, or an Access database, or an Oracle database, or....
And to connect to each different kind of database application, you need different commands (it's more or less like asking for certain papers in English or in Spanish -- you have to speak the language of that that is giving you the papers, not of the papers themselves.)
OleDb * classes are very general, and you can use those to connect to almost any kind of database, including Access and SQL Server. The only difference is in the provider part of the connection string. So, for simple databases, changing the connection string is enough to change from Access to SQL Server.
But SQL Server is way more powerful than Access. As Dave mentioned, you have stored procedures for example. And the Sql * clasess are specific for SQL Server, giving you better performance and access to SQL Server-specific features, but also restricting you from using other database applications.
By the way, there's a free edition of SQL Server, called Microsoft SQL Server Desktop Engine, which you can download from here[^]. It is SQL Server, with the only limitations of 5 concurrent users and 2 o4 GB per database (enough for most small applications (and for some medium apps too)).
If you have any more questions, feel free to reply to this thread, we'll be glad to answer them.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Thanks again LuisR (and others):
Maybe I was mislead by the book I am going through (by Wrox Press). They have a very specific set of examples where they are specifically naming the Northwind Database AND the program code that they provide in all of the example use SqlConnection, SqlCommand, etc. etc.
The author of the book claimed that the MS SQL Desktop Engine would be installed automatically if the .NET Framework SDK had been installed AND the Northwind database would also be supplied in a samples directory. As far as I could tell, this was not true. I could find neither the server or the sample database files on my system after installing the SDK.
So, I did indeed go to the MSDE site and download the free desktop server, installed it and then started tearing out my hair trying to get the examples to work.
My only explanation for all of this is that perhaps the Northwind sample database HAS been created or converted to MS-SQL format and this is what the book's author had intended.
I am happy that I at least have something working here. I have Access and I can create databases with Access and play with them through my C# code for a while and then move on.
Thank you again!
Jethro63
|
|
|
|
|
Thanks Luis, your post helped me to solve one of my problem.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
|
|
|
|
|
Is it possible to get a form to paint over the top of its child control without overriding the paint for the child controls?
My Problem
I’ve got a form that contains a number of panels. The panels all do their own painting. I am attempting to paint a grid on top of all the panels and I do not wish to set the panel’s transparency to transparent.
My attempted solution was to override the forms Paint method and paint the grid onto the form. However I can’t get this solution to paint over the top of the panels. Does anybody have any suggestions?
Many thanks
Mark.
|
|
|
|
|
Doesn't bringing the grid to the front (Right click, Bring to Front) help?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
hi all
i'm create code demo as the one in this link http://www.15seconds.com/issue/020917.htm[^]
after run this code i found that the cearted code file contain only these lines
using System;<br />
using System.IO;<br />
<br />
<br />
namespace CodeDom {<br />
<br />
}
if anyone know where is the error please inform me coz i need it urgantly
|
|
|
|
|
namespace codedemo
namespace is only one word, that the only error I see in the above code.
/\ |_ E X E GG
|
|
|
|
|
thnx for ur replay but this is not the error and i don't know why this code didn't work correctly
|
|
|
|