|
How would you add a CheckBox column in a DataGrid?
Any help on this topic will be appreciated. Thanks in advance,
Jon
|
|
|
|
|
As I mentioned the other day, add a DataGridTableStyle to your DataGrid , which would have either DataGridTextBoxColumn s, DataGridBoolColumn s, or some custom DataGridColumnStyle . Make sure the DataGridTableStyle.MappingName matches-up with the table name (for data-binding to DataSet s or DataTable s) or class name (for binding against other IList or IListSource implementations).
Just see the documentation for the DataGridTableStyle in the Platform SDK for more information and an example, as well as the other classes and properties I mentioned above. It's really pretty simple, but you must make sure that your DataGridTableStyle.MappingName is correct or your table style doesn't get used.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You are a great help with giving me exactly the key words to point me in the right direction. Iv'e created the DataGridBoolColumns style, and made the MappingName match the table column i'm "binding" it to. How do I tell it to display a CheckBox? I don't understand how they add the CheckBox control inside the columns.
|
|
|
|
|
Like I said, you add a DataGridBoolColumn to your table style that you added with it's MappingName set to your boolean column. If you use values other than "True" or "False" for your data, then you need to set the DataGridBoolColumn 's TrueValue and FalseValue properties. Just see the DataGridBoolColumn documentation for an example.
Also, try playing around with this in the VS.NET DataGrid designer and then examine the code. It works best if you use a typed DataSet .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
DataGridTableStyle ts2 = new DataGridTableStyle();
ts2.MappingName = "library"; // name of the table
DataGridBoolColumn boolColLib = new DataGridBoolColumn();
boolColLib.MappingName = "super"; // name of the column
boolColLib.HeaderText = "Super";
boolColLib.TrueValue = "true";
boolColLib.FalseValue = "false";
boolColLib.AllowNull= false;
boolColLib.Width = 70;
ts2.GridColumnStyles.Add(boolColLib);
dtgAppserver.TableStyles.Add(ts2);
it should work like this
|
|
|
|
|
Hello everybody...
Im used to program my games and stuff with C++ and WinAPI with OpenGL and/or GDI, GDI+...
My questions and thoughts is as follows:
1. Game programming with C# Advantages and so on...?
2. Is it possible to implement OpenGL to C#?
3. Why should I start to program in C#? Is thear any or many Advantages? Or not...
Marcus Grenängen
Lead programmer at MO Software Sweden.
|
|
|
|
|
Snews wrote:
1. Game programming with C# Advantages and so on...?
Easier to write but lacks the performance of native language applications.
Snews wrote:
2. Is it possible to implement OpenGL to C#?
Yes, but you must wrap OpenGL. There are some implementations of this already (even here on CodeProject, so just try a search), but some are good and some are not. In either case, considerable time is spent marshalling data across platforms. Depending on your requirements, this may not be desirable either.
Snews wrote:
3. Why should I start to program in C#? Is thear any or many Advantages? Or not...
The learning never stops. If you like to learn as much as you can, there's one good reason.
You should really take a look at Managed DirectX at http://msdn.microsoft.com/directx[^], which is managed code for DirectX and written from the ground-up - it's not a wrapper. There's a couple good books that cover game development using Managed DirectX (using both C# and VB.NET) from Amazon that are pretty good and also discuss the ads/disads:
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Like the anser on 3... Thats right... How does it work with the memmory processing and handling in C# then? Better and easier then in C/C++? or is it just crappy?
This Managed DirectX? I will take a closer look at it, even if I never have liked DirectX
Tanks for your time Mr...
Marcus Grenängen
Lead Programmer MO Software Sweden
|
|
|
|
|
Use managed DirectX instead. It's not at a very mature state yet (lacking some documentation and still have annoying bugs), but I'm sure it will become the preferred way of using DirectX pretty soon. Just compare managed vs unmanaged DirectX code (C++ vs C#) and you will notice the great improvement in readability and the superior object oriented model.
Even though I'm used to coding C++, I find C# code so much more readable, and more productive to use. Since the framework includes a compiler you can even use C# for the scripting part of the game (or JScript if you like that better).
Your ideal game project would be 95% C# code, and 5% C/C++ code mixed with assembler for the most performace critical parts. In some years, most people in game industry will use this model I think and hope.
Regards,
/Björn Morén
|
|
|
|
|
1. The advantages include less amount of code to write, cleaner syntax, no manual memory management, faster development cycles. Disadvantages include slower performance, access to platform level services only via P/Invoke.
2. You can use OpenGL in C#. As Heath mentioned, it's already been done. See CsGl[^], the Exo Engine[^], or the cross-platform Tao OpenGL library[^].
3. It's has simpler language syntax than traditional C++, which translates into code that's easier to read, write, and find bugs. Memory management is taken care of for you, preventing many pitfals of C including memory leaks and circular references. It generates verifiable 'safe' code which could be quite important when Microsoft's ClickOnce deployment rolls around. It interoperates with other .NET languages seamlessly without any extra effort; write a public Test() function in a dll and I'd be able to use it from VB.NET, managed C++, JScript.NET, or any other language targetting the .NET platform. Dlls can be stored in the Global Assembly Cache in which dll versions do not overwrite one another, potentially preventing the problems associated with 'dll hell'. See Microsoft's .NET overview[^] for a list of their benefits to using .NET.
Hope that answers some of your questions. To be honest, I don't know if C# is right for game development; C#, while theoretically faster than Java (due to being 'designed for JIT compiling') isn't as fast as C++, and doesn't directly give you access to low-level services in the same flavor as traditional C or C++ does. On the other hand, C++ is not as fast as C, and C is not as fast as pure x86 ASM code, yet that has not stopped developers historically from writing games in C++. I guess it's a tradeoff - speed for RAD. If you are more focused on finishing a game faster than writing a game that runs faster, use C#. If you are more focused on writing a game that squeezes every last drop of performance out, use C/C++/ASM.
FYI, some groups have done interesting game development work with C#. For instance, Vertigo software ported Quake II (written in C and ASM) to the .NET framework using managed C++. clickity[^]. As previously mentioned, Microsoft has released Managed DirectX 9[^]. Microsoft's new XNA[^] initiative plans to build on DirectX (including managed) and Visual Studio as tool bases as well.
|
|
|
|
|
CsGL is obsolete. Tao framework is it's "child" and is fully functional. And my friend has just finished wraping the CG so I think it will be aded in the next realese.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
C#, while theoretically faster than Java (due to being 'designed for JIT compiling')
I love how Redmond constantly tries to imply that JIT compilation is their bright idea. Java had JIT compilers long before the .NET brand was being marketed to the world. The execution speed of Java code, according to an IBM study, is about 1.7 times slower than equivalent Fortran code. Deep compilers, similar to ngen.exe for .NET, exist for Java and work well.
JIT compilation doesn't really say anything about the runtime speed of code, by the way. A good JIT compiler will compile code that runs faster than the output of a worse compiler. JIT compilation does, however, introduce some unavoidable slowness when something is first run, due of course to the compilation time required.
I implemented several applications side-by-side in C# and Java a while back, and they ran neck-and-neck on my setup. Java is faster in some respects, and .NET is a little faster in others.
I agree with everything you wrote except that; chalk this post up to having too much time on my hands on a Sunday afternoon.
Regards,
Jeff Varszegi
|
|
|
|
|
I did say 'theoretically', eh? Yes, Java has had JIT compiling for awhile I know, however, Java is more or less an interpreted language out of the box, with some so-called 'hot spot' JIT compilation as needed.
Yes, Java and C# are very close performance wise. I'd be willing to bet, though, that as C# matures, .NET will eventually outpeform Java evidently as the great compiler teams at Microsoft focus their brilliant brain-heads on it.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
The "HotSpot" compiler is just the name brand for Sun's compiler, which many people don't even prefer to use. All of the major compilers in use today are JIT compilers. "More or less interpreted" is a phrase that applies exactly as much to .NET as it does to Java.
There are also "brilliant brain-heads" at work trying to make Java run faster all the time. Every version has included speed improvements, just as is true between version 1.0 and 1.1 of .NET. I wouldn't be willing to bet that .NET will outperform Java eventually, because they're way too similar, and there's no magic. As they both creep more and more towards optimal implementations, their performance will probably become closer to identical.
I'm not arguing just to argue, but I wouldn't bet that Microsoft stuff will kick ass just because of the brand.
Regards,
Jeff Varszegi
EEEP!
|
|
|
|
|
Have a look at Purple# too. They have a project hosted on SourceForge.
|
|
|
|
|
Chers everybody for ansering my questions. It has become less foggy when thinking in C#, I will explore the OpenGL Potensials and also look at Managed DirectX.
Marcus Grenängen MO Software Sweden
|
|
|
|
|
I'm trying to create a Tree data structure whose externally revealed methods and properties will behave much like the System.Windows.Forms.TreeView. I noticed something strange, and I'm not sure how one would go about doing it. It could just be that I'm missing something simple, however.
You can do the following...
<br />
TreeView tv = new TreeView();<br />
tv.Name = "My TreeView";<br />
TreeNode tn1 = new TreeNode("1");<br />
TreeNode tn2 = new TreeNode("2");<br />
tv.Nodes.Add(tn1);<br />
tv.Nodes[0].Nodes.Add(tn2);<br />
<br />
MessageBox.Show(tv.Nodes[0].TreeView.Name + "; "<br />
+ tv.Nodes[0].Nodes[0].Parent.Text);<br />
The result will be "My TreeView; 1". Which means that tn1 knows that its parent TreeView is tv1, and tn2 knows that its parent TreeNode is tn1. This is weird, because nowhere did I tell tn1 about tv1, or tn2 about tn1, and the Parent and TreeView properties are read only.
Does anyone know how they did this? Or how I might go about mimicing them?
|
|
|
|
|
First of all, the TreeView encapsulates the Tree-View common control, the very same native controls that comprise Windows Explorer and many more applications - the same with most of the Windows Forms Controls. The TreeNode encapsulates the TVI_* messages for the Tree-View common control.
If you plan on doing this yourself, then your tree nodes keep a collection of other tree nodes. When a tree node is inserted into the collection, you assign private or internal properties (depending on your object model) that set both the parent node and the container (like the TreeView ). For tree views that don't encapsulate native controls (and define a tree view from scratch), this is generally what's done, like the UltraWinTree from Infragistics[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am having a problem with the Directory package. I need to create a list of a root directory and all of the sub-directories associated with that root. I am currently using the System.IO.Directory.GetDirectories(_PathName) to get a list of the first level of subdirectories. This returnes a string array of the subdirectories. Now i need to go anothers step down and check all of these subdirectories for additional subdirectories. The problem is that i could do this but i am not quite sure how to extend this for an unknown amount of levels within the directroy structure. Any help would be appreciated.
Thanks
|
|
|
|
|
Hi
this is a code i use to copy a directory tree..
and I readthe directory tree..(The same as your program)
read it and get the idea
private void cmdCopy_Click(object sender, System.EventArgs e)<br />
{<br />
if(!Directory.Exists(txtDist.Text))<br />
{<br />
MessageBox.Show("Please enter a valid path");<br />
return;<br />
}<br />
DirectoryInfo dir=new DirectoryInfo(txtSrc.Text);<br />
CopyDirectory(txtSrc.Text,txtDist.Text+"\\"+dir.Name);<br />
MessageBox.Show("OK");<br />
}<br />
<br />
private void CopyDirectory(string src,string dist)<br />
{<br />
if(!Directory.Exists(dist))<br />
Directory.CreateDirectory(dist);<br />
<br />
FileInfo file;<br />
DirectoryInfo dir;<br />
string[] strFiles;<br />
string[] strDirs;<br />
<br />
strFiles=Directory.GetFiles(src);<br />
foreach (string strFile in strFiles)<br />
{<br />
file=new FileInfo(strFile);<br />
file.CopyTo(dist+"\\"+file.Name);<br />
}<br />
<br />
strDirs=Directory.GetDirectories(src);<br />
foreach (string strDir in strDirs)<br />
{<br />
dir=new DirectoryInfo(strDir);<br />
if(dir.FullName==dist)
continue;<br />
CopyDirectory(dir.FullName,dist+"\\"+dir.Name);<br />
}<br />
}
|
|
|
|
|
Does anybody know of a way when developing your own VS.NET add-in, to access all the server connections? What I want to do is grab all the tables from the databases listed in their and place them on a treeview in my addin.
I know its not the best place to post this, but there is no "CRAZY QUESTION YOU WOULD ASK WHEN WRITING AN ADD IN FOR VS.NET" forum is there guys? (blush)
Ta!
Nursey
|
|
|
|
|
Hi,
I made 2 custom controls, both of which have a default constructor. The problem is that when I try to drag one of them into the form from the toolbox, I get a message saying that an exception occured while trying to create an instance of the control. The exception text is "Object reference was not set to an instance of an object."
Now with the other control, it works Ok when I drag it onto the form and works as expected when I run the program, however if I try to delete it from the form I also get an "Object reference was not set to an instance of an object." exception.
Can you please help me locate the source of this error?
Thanks for your help.
Josef
|
|
|
|
|
Problems found and fixed.
Thanks,
Josef
|
|
|
|
|
hi, am trying to load values from config file in windows service project installer but it fails to load, then i tried to load that config file using xmldom, it worked but in this way installer looks for the file in system32 directory rather than in my installation directory.
How can i do that
|
|
|
|
|
The application's .config file is read from the same directory as the application executing your installer - not the installer itself. So, if you use the installutil.exe, then installutil.exe.config is used from the same directory where installutil.exe is executed (not the current working directory).
You should typically not use .config files with installers for this reason - your installer class is typically contained in a DLL and executed by something else. Instead, accept command-line parameters which make it more flexible, easy to document (see the Installer.HelpText virtual property), and easy to use even with Windows Installer packages (which you can pass properties as command-line parameters.
See the Installer.Context property documentation in the .NET Framework SDK for more information and an example of how to get those properties from the installer's context.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|