|
Mika Wendelius wrote: I read the format typically from database
For this utility I'll get it via XML file, but the user who creates the file should be able to specify what he wants without knowing much about the internal plumbing.
An added bonus to how I envision working around this problem responding pro-actively to this opportunity is that I can allow multiple sub-formats in the format.
With string.Format I can use "{0:X4}={0}" to format the same value into the output twice, but ToString doesn't seem to support that on its own: 20.ToString ( "X4'='0" ) results in X4=20 .
But if I pre-process the format, I can add support that I feel ToString should have; split the format into { "X4" , "'='" , "0" } , then iterate and if the sub-format is literal text, output it (Append to a StringBuilder), otherwise pass the sub-format to ToString and output the result.
The resultant process should then better match how I understand ToString should work with custom numeric formats.
|
|
|
|
|
|
Well, that, was easy. I just don't think it's enough to form its own article.
20.ApplyFormat ( "'0x'X\"=\"0d" ) yields "0x14=20d"
|
|
|
|
|
Seems easy, but a stupid question: What's ApplyFormat? It doesn't seem to be any .Net method for int.
|
|
|
|
|
Ah, see? Obfuscation. That's the Extension Method I just wrote.
|
|
|
|
|
That's what I thought
Well, if the implementation is more than one line perhaps you should still consider the article
|
|
|
|
|
Yeah, I think I will.
But I've also been directed to Customizing Format Strings[^], so I'll look through that to see if it may be a better or complementary technique.
|
|
|
|
|
I submitted the article, we'll see what happens.
|
|
|
|
|
Is this the right spot to ask questions about Visual Studio 2008 extensibility?
I am writing a Visual Studio 2008 Integration Package, using the SDK, and I would like to attach behavior code to the designer drag events (DragEnter, DragOver and DragDrop). I have a custom tool window with a list of available commands to our electronic measurement device. I want the ability to drag a command from that list onto the surface of a winform designer. Dropping the command item should automatically create the default control type and write the code that hooks it to the equipment command. Alternatively, I'd like it if the user could drag a command onto an existing control and have the connection code written.
I think I see how to automate the creation of controls and code in a Form designer, but I can't figure out how to hook that code to the designer drop event.
Thanks,
Aaron
|
|
|
|
|
As far as extending the designer capability for controls, one of my articles might be able to help you: Targeting Design-Time Events of UserControls[^].
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Hello,
In VB.NET or C# (and generaly in DOT NET)
How to get the Owner / Creator of a document / file ?
I know hot to get modification date, creation date
but not the OWNER of the file.
How to access to the Security Attributes in order to get the OWNER ?
Best regards
|
|
|
|
|
Off the top of my head, you can use WMI and the System.Management namespace to get the Win32_LogicalFileSecuritySetting[^] object for that file. Call it's GetSecurityDescriptor method and that will return a Win32_SecurityDescriptor[^] object, which will have the information you're looking for in its Owner property.
|
|
|
|
|
Use the FileInfo.GetAccessControl() method to retrieve a FileSecurity object. Then call FileSecurity.GetOwner() to get the owner of the file.
|
|
|
|
|
Can someone please recommend me good resources on distributed computing and multithreaded programming that will get me started quickly but not be too brief in their usefulness...oh and doesn't cost an arm and a leg? Nothing really jumped out at me on Amazon.com. All the books I noticed were either $100+, written in the 90's or not rated.
Thanks
|
|
|
|
|
Not an answer, just a quick reading-tip; search for the article here on CP about "Legion"
I are troll
|
|
|
|
|
now, I want to delete one record on datagrid when I checked checkbox.
there is a checkbox on datagrid.
for example; if I checked checkbox on second row. The second row will deleted.(button click event)
how can i do this...
|
|
|
|
|
Did you try searching google first?
If so you may have found this[^].
I don't know how are you binding the grid with the data but as a simple solution, I would say just a do a postback when the checkbox is checked and use the RemoveAt method of DataRowCollection.
Be careful, there is no Undo Button(Ctrl+Z) in life.
|
|
|
|
|
hi,
am working in .net 2005 with c# coding.am a fresher.
i need javascript for validating the empty textbox. and also how to call the javascript in source code.
if anybody know the script.
plz help me.
thanks®ards,
vinoth.T
|
|
|
|
|
vinothtamilarasan wrote: i need javascript for validating the empty textbox.
I think you need this[^] more than the textbox validation script. You should get familiar with the JavaScript first rather than asking for the solution directly.
Be careful, there is no Undo Button(Ctrl+Z) in life.
|
|
|
|
|
You can use something like this-
function validateEmpty(fld) {
var error = "";
if (fld.value.length == 0) {
fld.style.background = 'Yellow';
error = "The required field has not been filled in.\n"
}
else {
fld.style.background = 'White';
}
return error;
}
function validateFormOnSubmit(theForm) {
var reason = "";
reason += validateEmpty(theForm.field1);
reason += validateEmpty(theForm.field2);
reason += validateEmpty(theForm.field3);
if (reason != "") {
alert("Some fields need correction:\n" + reason);
return false;
}
return true;
}
Replace 'field1', 'field2', and 'field3' with the correct names. You can add and subtract as well. The alert box will output a line delimited list of all error messages. Call the function like this-
<form name="demo" onsubmit="return validateFormOnSubmit(this)" action="action.aspx">
Try that out. Good luck!
Ranjit Viswakumar
Professional Services Specialist
HostMySite.com[^]
|
|
|
|
|
Good day to all ...!!!
Hopefully I can help, I have a problem when working with reflection. I have a dll (called midll.dll) from which all classes have a class named Class1 with their respective attributes. When I try to get an object of this class have to do it by reflection through a Construtor with their parameters (I have stored on the array objects. The array objects called parametersConstructor). Therefore, with the next statement I make this job:
(The parametersConstructor have 2 values)
objObjet2 object = Activator.CreateInstance (assembly.GetType (mydll.Class1 "parametersConstructor); // The assembly is complete
The result is that the object you want to get, and I have no problem, since it does not skip any exceptions to this point.
But the problem is that I realized that one of the attributes of the object is created with one exception. The exception is the following:
atribute4Class1 -> Count = '((System.Collections.Generic.Dictionary <tkey,tvalue>. ValueCollection) (((midll.Class1) (objObjet2)). atribute4Class1)). Count' throw an exception of type 'System.ArgumentException '
Following a little more depth error (it should be noted that there was a lot of where to find the source of the error), what most caught my attention is that at some point I said the following:
Can not find the method of the object instance. (Not specified object that refers)
Personally I thought the problem was with the class, because to say that no method of the object instance, you will most likely have problems with objObjet2 casting that is specified in the original exception.
I thought it was a problem with the class Class1, but discarded, since the same class instance as follows:
Class1 obj = new Class1 ((string) parametersConstructor [0], (string) parametersConstructor [1]);
And the object is created without any problems and even less is not generated except that I mentioned earlier.
Anyone have any idea why this is? Thank you for your help ...!!!
Atte:
Wilson Carchi A.
Software Developer
|
|
|
|
|
Your writing is very difficult to understand.
I suggest you first ensure that the GetType is successful before trying the CreateInstance.
|
|
|
|
|
I can't seem to make the Combobox4 text to reflect the changes made and still pointing to the "Edit..."
Dim mylink As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Application.StartupPath + "\Data\BW.mdb")
If Me.ComboBox4.Text = "Edit..." Then
Dim NewLink As String = InputBox("Type the desired URL to Business Warehouse Inbound", "Business Warehouse SAP")
If NewLink.Length > 0 Then
Dim Outbound As String = "UPDATE _servername SET Outstring ='" + NewLink + "'"
Dim OutFld As OleDb.OleDbCommand = New OleDb.OleDbCommand(Outbound, mylink)
Dim affectedrows As Integer
mylink.Open()
OutFld.Prepare()
affectedrows = OutFld.ExecuteNonQuery()
mylink.Close()
End If
End If
Dim sql As String = "SELECT * FROM _servername" 'Refresh
Dim da = New OleDb.OleDbDataAdapter(sql, mylink)
Dim dtSvr As New Data.DataTable("_servername")
da.Fill(dtSvr)
Me.ComboBox4.Text = (dtSvr.Rows(0).Item("Outstring")).ToString
|
|
|
|
|
Is the combobox's DropDownStyle equal to DropDownEditList . If it is, yuo should change it to DropDown . If that's not the case, use debugger to see that the ComboBox4.Text is set correctly.
Just a sidenote, you should use parameters in your sql commands instead of concatenating.
|
|
|
|
|
The Combobox4.Text shown correctly then afterwards (like refresh) it went to the selected item called "edit..." see my codes
|
|
|
|