|
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.
|
|
|
|
|
hi,
You can sumbit this question in our Asp.net discuson.
i can suggest one solution of this.
Try to set the value of AutoPostBack property to false.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
thanks, forgot which forum i was in.. reposting in ASP.net
Yes, I am the highly suggestable type.
|
|
|
|
|
Hi all! I have a wierd problem and I can´t understand why it happens.
I have a couple of html pages that I read from and write to.
When I read and write I use FileStream.ReadByte() and FileStream.WriteByte(). The problem I have is that when I view the file in IE after it is done, IE can not recognise the my swedish characters ( å,ä,ö ).
What really bothers me is that if I take the source of the page via IE and copy paste it into a textfile and give it the extension html there are no problems at all. There is absolutely no differences between the files that work and the ones that does not work, the content of the pages are the same, but still IE can read one and not the other..
There have to be some differences in some part of the not visible content of the files, but how do I resolve the problem? I need to save the files, and in my current implementation I would like to use stream.WriteByte() but I would also like to keep the swedish characters. Please advice..
/ Mikke
|
|
|
|
|
It is usually inappropriate to write text (html) at the byte level. This is because modern unicode strings do not have a simple 1 byte = 1 character mapping.
What is probably happening is that the file you are reading from is in one text encoding (e.g. UTF8), and the file you are writing to is in another (e.g. ASCII).
Just read and write strings, and you should be fine. It may help to educate yourself on text encodings first though.
One of the better articles on this subject is from Joel on Software.
my blog
|
|
|
|
|
Steven's right, but what you need to do is actually quite easy.
Wrap your FileStream (or whatever Stream derivative you're using) in a StreamReader or StreamWriter , which makes reading and writing text much easier. You can specify the encoding (like Encoding.Unicode, since you're probably dealing with Unicode characters on the 'net, or UTF8 which is most common (a multi-byte character set, or MBCS)) and with the <code>StreamReader you can set a parameter in the constructor that attempts to detect the encoding by detecting a byte-order mark (BOM).
For example:
using (FileStream file = File.Open("somefile.html", FileMode.Open))
{
string line = null;
using (StreamReader reader = new StreamReader(file, Encoding.UTF8, true))
{
line = reader.ReadLine();
}
} The using blocks make sure the streams are closed (i.e., the native file handles are released - very important or your performance is hampered, or - worse yet - you have memory leaks).
You should really read about the Encoding class in the .NET Framework SDK. You could still read and write bytes but you must understand that ANSI is a single-byte character set, and may use different code pages. ASCII characters use only 7 bits in the byte (the first 128 values). The last 128 values can be different depending on the codepage (local characters, or defined for particular systems). UTF8 can handle ASCII characters, but those latter characters actually tell the decoder to use 2 bytes to read the character, thus supporting Unicode as well. This is a great encoding to use on legacy systems, especially if you're not sure what a text file will contain (although a legacy decore might have problems). Unicode comes in many flavors, and you can read more on the web if you try a google search or click "Search comments" above for previous discussions we've had about this.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi! Thanks alot! Both to Heath and Steven!
Will try this first thing monday morning!
The Joel on Software text gave som intresting, and fun!, reading.
/ Mikke
|
|
|
|
|
Hi,
Im writing a component for posting data to a webserver.
http://www.domainname.com/fire/incoming.asp?user=xxxx&pass=xxxx&amount
I tried using HttpWebrequest & Webclient to post data but it is returning an error
if i paste the url in the browser it is working properly
The code goes here
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string User = "test3";
string Pass = "test3";
string amount = Server.UrlEncode(TextBox2.Text);
string MobileNumber = "91"+TextBox1.Text;
string postData = ("login="+User);
postData += ("&pass="+Pass);
postData += ("&amount="+amount);
string uriString = "http://www.domainname.com/fire/incoming.asp";
WebClient myWebClient = new WebClient();
myWebClient.Headers.Add("Content-Type","application/x-www-form-urlencoded");
byte[] byteArray = Encoding.ASCII.GetBytes(postData);
byte[] responseArray = myWebClient.UploadData(uriString,"POST",byteArray);
lblStatus.Text = Encoding.ASCII.GetString(responseArray);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Can someone help .....
Thanks in advance
Abraham
|
|
|
|
|
I want to do a maskedit control that it like powerbuilder or delphi's maskedit
control.
|
|
|
|
|
Great...what's your question?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi all,
I would like to program in c# a graphical design tool like ms visio. I need the functionalities of component inserting, deleting, resizing, moving, component connecting and so on. Someone knows sample codes or tutorials?
Thx
|
|
|
|
|
I would say that is more of an OO thing than an algorithmic thing.
For example, you have two classes called DrawingSurface and Component .
DrawingSurface has a collection of Component s
To Insert you instantiate a component (Component theComponent = new Component() ) and add it to the DrawingSurface (DrawingSurface.Add(theComponent); )
To Delete to remove the component from the DrawingSurface (DrawingSurface.Remove(theComponent); )
To Resize you would have properties on the component like Width and Height . You might trigger an event on the setters of these properties that the DrawingSurface would handle to redraw the diagram.
To Move you would have position properties on the component like X and Y . And again in the setters you would probably fire off an event that the drawing surface uses to redraw the display.
And so on and so forth.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
I've tried to create a custom progressbar to display while I'm doing some intensive work. I also want to update a string of what is currently going on, like an installer tells the user what file is currently being copied, and so on...
So, I have a form that I display and then call methods like
<br />
MyProgressForm.setProgressText(string)<br />
MyProgressForm.setProgress(int)<br />
but the GUI components (a label for the text and a custom-painted control for the progress) won't get updated, I guess because there is too much work going on...
So my question is, how do I force these to be updated?
What is the best way to solve this?
thankful for some help, I can't seem to figure it out ...
|
|
|
|
|