|
i am sory, my problem explaination was not enough at all.
first, i bound a DataTable to my DataGrid.
my problem is:
i have a TreeView in the same form of the dataGrid.
1. According to a specified condition I colored some of the datagrid cells (i color only the left section from the cell (assume red)).
2. For each TreeNode in this TreeView i make the value of some datagrid cells to be "true", in addition, i color the right section from this cell (assume green).
In the event treeView1_AfterSelect, i empty the DataTable to receive a new data for the new TreeNode. When i do this the color of the right section (green color) is alse deleted.
a) I want to keep this (green) color to be seen along all TreeNodes selection to ensure unique data selection (or no data is selected towice) for different treeNodes.
b) in addition, i want to return the cells that have a "false" value and a red color
thanks alot
|
|
|
|
|
hi,
What heath says is correct. And here i can give one more solution that is datagrid tablestyle. You can check my datagrid related article. There i mentioned rich usage of DataGridTableStyle class.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I am creating a control assembly to house custom controls. I found the attribute that I can use to specify a custom bitmap but cannot find out how to specify the Tab to which my controls will be installed. I know I can manually move the controls around but I want to distribute this assembly to my team and have the components installed into a single custom Tab. Any ideas?
|
|
|
|
|
There's several ways of doing this, but none so easy as just using an attribute. You can use the VSIP (Visual Studio Integration Program) SDK - which you can find at http://msdn.microsoft.com/vstudio/extend/[^] - to install your controls into a toolbox group into Visual Studio while installing your control library. That's how most vendors do it.
You can also, if you can get a designer running in Visual Studio, use services to temporarily install toolbox items. Read about the IToolboxService in the .NET Framework SDK. There's a lot of links and examples to more information.
There are a lot of other design-time classes that may be helpful, such as the ToolboxItemAttribute and the related ToolboxItem classes, as well as the ToolboxItemFilterAttribute that shows or hides a toolbox item depending on what's currently being designed (or edited).
A good place to start reading about design-time extensibility is Enhancing Design-Time Support[^] in the .NET Framework SDK.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi,
I'm just getting to grips with xml serialization, and I want to load this XML...
<?xml version="1.0" encoding="utf-8" ?>
<Files>
<AudioFile url="file.xyz" date="08/07/06">
<comments>Hello</comments>
</AudioFile>
<AudioFile ... >
...
</AudioFile>
</Files> I have an AudioFile class ready for deserialization of an AudioFile node, and I want to load all the AudioFile nodes into an ArrayList. What's the easiest way to do this?
I need this to make a data source for an Asp.net Repeater control... is there an altogether better way to do this for a very small number of entries?
Any help is much appreaciated...
Joel Holdsworth
|
|
|
|
|
You can't load that with XML Serialization. Collection objects - even with the XmlRootAttribute , will always have ArrayOfSomething , depending on a number of factors. Now, if you change <Files> to <AudioFiles> , you may have a chance. If you derive an object-model where AutoFile extends File , you might also have a chance.
Basically, read about the attribute classes in System.Xml.Serialization for more information about how to control the serialization and deserialization of classes using XML.
In many cases, however, trying to derive an object model from XML is far more difficult than creating the object-model first then creating the XML format, if you can.
Also, any IList or IListSource is data-bindable, so any list class - like ArrayList - can be bound. Typically, though, it's better to derive your own IList implementation rather than use ArrayList because you can attribute it how you need.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I have combobox custom control developed by my collogues in C#. I reuse it often in my project. I have some problem when I reopen my project in V.S. Like if I make some changes, add some more standard control and save it. The visual studio envirnoment deletes this custom control from the form. It deletes all the entries of this CC from both .cs and .resx file.
Any idea why this is happening ? And how to avoid it ?
I have a work around for this when ever I have to add new control I manualy edit the CS file in notepad (Its pain, bcoz got use to VS no more programming in Windows SDK). But I don't modify the .resx (because its complecated XML). Does this ( not modifying .resx file ) cause any problem ?
Sandeep Naik
|
|
|
|
|
Does your friend's comboBox custom control constructor requires some argument?
If yes. That is causing the problem. Actually only default constructors are supported by .Net Designer.
Making designer to support the overloaded constructors with arguments, requires some additional things to do. I am not very clear about this. Some body else may give you more detail informations.
Regards,
Jay
|
|
|
|
|
|
for example i have a small programm with a picture inside.
can i protect this picture form making screen shot by pressing screen shot key( but its not so imporant) can i catch an event if some other program prepars to make a screen shot?
ist it possible to protect my picture?
thanks in advance!
|
|
|
|
|
No, not unless you write directly to the screen buffer (write directly to the graphics device instead going through GDI or GDI+). .NET is too high-level for this, and you'd would have to do a lot of work to make it happen (involves difficult work using the Windows DDK, or device driver kit), and you really have to understand device drivers the Hardware Abstraction Layer (HAL).
A better way, perhaps, is to use Managed DirectX, which you can download at http://msdn.microsoft.com/directx[^]. Using the right options with DirectDraw, you can right directly to the screen buffer and taking screenshots - which uses GDI to bitblt the desktop or a particular window - won't see it. This is currently what Windows Media Player (along with some other media players) do to prevent you from taking screenshots of a video (unless you're using a program that rips a frame directly from the decoded bits).
If you want to read a good book on Managed DirectX, read Managed DirectX 9 Kick Start : Graphics and Game Programming[^].
To note, Managed DirectX requires the DirectX runtime to be installed, as well as the Managed DirectX libraries. You can read more about this in the Managed DirectX SDK (which is what you'd download from the link above), as well as the deployment documents you can also find from that link.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hello,
I am trying to implement a checkbox column in a datagrid that will provide the user the ability of checking certain rows that they want to perform some action on. Here is my problem. Originally, I just added a new row in my database called "Checked". This seemed to be working okay until I started trying to implement a "Select All" functionality. In order to do this, I have to loop through each row in my datatable and set the value for the "Checked" column to true. This takes forever because there are 13,000 rows in the table. My question is this: is there any way to add a column to a datagrid without having it bound to a column in the datatable? What other options are there for doing something like this?
I guess I could just use the regular select functionality of the datagrid, but this requires the user to hold down control to select multiple rows.
Any ideas?
Thanks,
Blake
|
|
|
|
|
hi,
Please check this datagridgirls.com. This site contain few articles which deals datagrid customization. Sure you will get solution.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi,
I've got a class with an Options property. I'd like to implement this property in a way that a calling syntax like
MyClassInstance.Options = MyClass.Option1 | MyClass.Option2;
can be used. My questions with that:
1. How do I store these BitFlags internally?
2. How do I check for whether certain Bits have been set.
3. The above code shows how to switch 2 bits ON (hopefully, correct me if I'm wrong). How would the syntax look If I'd like to switch Option1 ON and Option2 OFF?
I'd highly appreceate a short example!
Thanks in advance.
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
|
|
|
|
|
Think of flags as good ol dipswitches , 32 of them numbered from 32 to 1. The integer value of a flagged value represents the indices of which flags are ON (or true)
4-bit example:
enum foo : 4bit
{
toggleA = 0001,
toggleB = 0010,
toggleC = 0100,
toggleD = 1000,
}
value1 = 0101 = (toggleC | toggleA) = (0100 | 0001)
value2 = 0100 = (toggleC & value1 ) = (0100 & 0101)
value3 = 0001 = (value2 ^ value1 ) = (0100 ^ 0101)
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Define an enumeration with the [Flags] attribute, which I recommend you read about. See FlagsAttribute in the .NET Framework SDK. Do not define them as properties or fields of your class unless they're simply numbers, not complex types. Enumerations are best used, and are used throughout the .NET BCL, like the Anchor enumeration used for the Control.Anchor property, among many, many others. Here's an example:
[Flags]
public enum Options
{
None = 0,
Option1 = 1,
Option2 = 2,
Option3 = 4,
Option4 = 8,
Option5 = 16,
Option6 = 32,
Option7 = 64,
Option8 = 128
} Without the flags, you get a compiler error stating that you can't perform bitwise manipulation with your enumeration.
To check if an enumeration is present, you use bitwise operators which you can read about at http://msdn.microsoft.com/library/en-us/csref/html/vclrfCSharpOperators.asp[^].
For example, if you want to check if your property contains Options.Option4 , you could do:
if ((myClass1.Options & Options.Option4) != 0)
{
} Note that the naming guidelines instruct you to name enumerations without the FlagsAttribute as singular, while enumerations with the FlagsAttribute should be plural. This is because the former can only set one, while the latter can set multiple.
To "store" (assign) these in your class, define your property as your enumeration type:
public class MyClass
{
private Options options;
public Options Options
{
get { return this.options; }
set { this.options = value; }
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi Heath,
Everything I needed! You got my five and a big thanks!
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
|
|
|
|
|
Try this article[^]
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Problem:
Grid shows several rows of data but all the cells are blank. I have a UserControl on a form that contains several grids. All the grids are populated using a DataTable.
Populate the grids through properties of the UC from the parent form.
Resolution Research:
1. The grid shows the expected number of rows.
2. I pause the program on a double-click event to evaluate the content of the Datasource. I find the datasource contains the expected number of rows and the columns contain the expected data.
3. The color of the ForeColor was WindowText so I changed it to Black. Still blank.
4. Added a MessageBox.Show() on double-click to view the contents of the row cells (this is cell content, not DataRow content). The displayed data is the expected cell content.
5. Added a new grid but did not change a single property. Added a line to the property of one of the other grids setting the DataSource=value . Got same result with new grid! Rows show but cell content look blank.
Any ideas why the grids refuse to show the content of the cells?
|
|
|
|
|
This fragment of code seems to work OK:-
void reversebytes(ref byte[] bout,int count)
{
byte[] b = new byte[count];
int i;
for(i=0;i
|
|
|
|
|
|
My test to reproduce:
[Test]
public void TestOpPrecedence()
{
int i = 10;
int count = 15;
Assert.AreEqual(4, count - 1 - i);
Assert.AreEqual(4, count - i - 1);
Assert.AreEqual(10, i);
Assert.AreEqual(15, count);
byte[] bytes = new byte[5] { 0, 1, 2, 3, 4 };
Assert.AreEqual(4, bytes[count - 1 - i]);
Assert.AreEqual(4, bytes[(count - 1) - i]);
Assert.AreEqual(4, bytes[count - i - 1]);
}
It works for me.
my blog
|
|
|
|
|
Hi,
How to convert string to WideChars when calling a legacy dll from .Net?
Thanks.
|
|
|
|
|
You don't - strings are wide characters (Unicode) by default in .NET. You actually have to convert to ANSI when calling native functions on Windows (as opposed to Windows NT).
We have convered this countless times in the past, so I urge you both now and in the future to search first for previous similar questions. You can search this forum by clicking "Search comments" above.
For an introduction to marshaling strings with Platform Invoke (P/Invoke), read Marshaling Strings[^]. Basically, when you use the DllImportAttribute to P/Invoke native DLL entry points, or define a structure for use with a native function using the StructLayoutAttribute , you set the CharSet field that both have to CharSet.Ansi (default for P/Invoke) to call only ANSI functions (where native strings are declared as char* ), CharSet.Unicode to call only Unicode functions (where native strings are declared as wchar_t* , almost always the case for OLE/COM), or CharSet.Auto when you want to call ANSI functions in Windows (i.e., Windows 9x/ME) and Unicode functions in Windows NT (i.e., Windows NT 4, Windows 2000, Windows XP, Windows 2003, and "Longhorn", plus all future Windows platforms). Windows only supports ANSI (although there is a Unicode layer, but that's an extra install) and Windows NT typically supports both but it's better to use Unicode because it allows for a much larger character set and you don't have to mess with codepages.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I have recently created a form that gives the user the option of filling out certain information in either text fields, or as file attachments, or a combination of both.
The problem i am runninginto, is that if the user clicks the browse button and selects a file, then hits any of the other controls that do a postback, the selected file is lost.
I have tried using this.filefield.EnableViewState = true to see if that would keep, but it doesnt. i also have not been able to progromatically assign a value or a PostedFile.Filename. the page errors out and says that they are not "settable" (gotta love "msenglish")
if i could grab the information and pass it to a hidden field, or allow the viewstate to hold it, that would be great. My only other recourse is to make it so that selecting files to upload is the LAST thing that can be done before submission, but that is a pain in and of itself, and doesnt do doodily squat for the user if they have to go back and redo something before submission. they would have to start any files they wanted to upload all over again...
Yes, I am the highly suggestable type.
|
|
|
|
|