|
hi,
please see the url
www.datagridgirls.com
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
If an image is inserted in the RichTextBox at runtime, how to drag/move it inside the RichTextBox with the help of mouse, just like we can move any control on the form during design time.
Please guide![D'Oh! | :doh:](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_doh.gif)
|
|
|
|
|
You can see it in
http://www.codeproject.com/cs/miscctrl/csexrichtextbox.asp
kunkun
|
|
|
|
|
well, thanks for the reply, but that will not solve my problem.
Inserting an image is not the problem, what I want to do is, dgra/move the image that is already present inside the RichTextBox with the help of mouse.
regards
|
|
|
|
|
Is the a way to do Copy Paste fom a ListView? I couldn't found anything on this, I tried Clipboard but it requires to trap Ctrl + C / Ctrl + P so I don't have any clue how to accomplish this. Anybody know please help me.
Thanks in advance.
|
|
|
|
|
Handling key strokes is the easy part. Handle the ListView.KeyUp event and check the KeyEventArgs.KeyCode and KeyEventArgs.Control properties:
listView1.KeyUp += new KeyEventHandler(OnKeyUp);
private void OnKeyUp(object sender, KeyEventArgs e)
{
if (e.Control)
{
if (e.KeyCode == Keys.C) Copy();
else if (e.KeyCode == Keys.P) Paste();
}
} To copy, grab the selected ListViewItem s, pack them in a DataObject , and send to the clipboard. Note that this will only work within the same AppDomain:
public void Copy()
{
DataObject do = new DataObject("ListViewItems", listView1.SelectedItems);
Clipboard.SetDataObject(do, false);
} To paste, you unpack the copied data (if relevent) and insert into the ListView :
public void Paste()
{
IDataObject do = Clipboard.GetDataObject();
if (do != null)
{
IEnumerable items = (IEnumerable)do.GetData("ListViewItems");
if (items != null)
foreach (ListViewItem item in items)
listView1.Items.Add(item);
}
} Note that this code is untested but should give you a start of what you need to do. Implementing drag and drop is not much different.
Again, remember that this will only work within an AppDomain. To copy and paste ListViewItem s between two separate AppDomains (ex: two different instances of a Windows Forms application), you need to marshal the data. You could marshal it as a string (encode the selected ListViewItem s as a string, then decode it in the other AppDomain), or a number of other things that would be difficult to do in a managed application (like alloc'ing the items in global memory, though with objects tied to a HANDLE (native pointer) that isn't so easy).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I'm looking to make an IE toolband (you know like google toolbar) and Haven't been able to find anything on where to get started. Could anyone give me a push in the right direction?
Matt Newman
...armed with what? spitballs!? - Zell Miller
|
|
|
|
|
http://www.codeproject.com/tools/netnamespace.asp
Many more examples if you search the forums and articles.
Judah Himango
|
|
|
|
|
|
Hello!
Anyone know of any bitorrent library och client that is made in C#? Or maybe some article about the subject?
Thanks in advance!
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
No, but I know of at least one in Java, (which can be converted to C#).
Azureus
my blog
|
|
|
|
|
You don't know of any very simple opensource java client? =) Azureus is to much of code for me to understand and organize =)
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
I've got a page with two panels. The first panel contains the search parameters (textboxes and drop downs). The second panel shows the results of the search.
On the result page, i allow paging and sorting.
Everything works great if i rebuild the dataset each time i change pages or change the sort. But when I cache the dataset in ViewState and try to change pages or the sort, it just takes my back to the parameter page automatically. Nothing else happens.
Here's my code for the Sort:
<br />
ViewState.Add("str_sortOrder", e.SortExpression);<br />
<br />
DataView dvwResults = new DataView();<br />
dvwResults = dst_searchResults.Tables[0].DefaultView[0].DataView;<br />
dvwResults.Sort = ViewState["str_sortOrder"].ToString();<br />
<br />
this.dgr_searchResults.DataSource = dvwResults;<br />
this.dgr_searchResults.DataKeyField = "aut_companyID";<br />
this.dgr_searchResults.DataBind();<br />
All help is appreciated.
Brian
|
|
|
|
|
Please redirect your question to the appropriate forum, the ASP.NET[^] forum.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi people, is there anything in C# that resembles "org.apache.log4j.PropertyConfigurator"[^]?
I'm looking for something that can loads configuration files and do all the dirty work for me... It should..., for instance:
PropertyConfigurator configurator = new PropertyConfigurator();
configurator.load(configFilePath);
System.Collections.Hashtable params=configurator.ConfigParams;
...
IDictionaryEnumerator enum = params.GetEnumerator();
while ( myEnumerator.MoveNext() ) {
Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value);
... do whatever else you'd like with the parameters ...
}
...
configurator.save(configFilePath);
If it's not part of dot-NET Framework, any Open Source you'd recommend? Thanks in advance.
Norman Fung
|
|
|
|
|
There's already a configuration framework in place for the .NET Framework. Read about the IConfigurationSectionHandler interface at http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemConfigurationIConfigurationSectionHandlerClassTopic.asp[^], as well as many configuration section handlers that are already implemented like NameValueSectionHandler[^] and others listed as implementations on the documentation for IConfigurationSectionHandler . Using this framework for configuration files unifies configuration - from runtime settings to application settings - for .NET applications.
To read more about how configuration files work in .NET as well as how to implement your own sections, read Configuring Applications[^] in the .NET Framework.
So, if you wanted a key/value pair configuration section, you could reuse the NameValueSectionHandler like so:
<configuration>
<configSections>
<section name="mysettings"
type="System.Configuration.NameValueSectionHandler, System" />
</configSections>
<mysettings>
<add key="opt1" value="myvalue" />
<add key="opt2" value="somevalue" />
</mysettings>
</configuration> To use this in your code:
using System;
using System.Configuration;
class Test
{
static void Main()
{
NameValueCollection settings = ConfigurationSettings.GetConfig("mysettings");
foreach (DictionaryEntry setting in settings)
Console.WriteLine("{0} = {1}", setting.Key, setting.Value);
}
} It's important that your configuration file match the executable name for your Windows Forms application or Windows Service (i.e., if your .EXE is named myapp.exe, then you're .config file is named myapp.exe.config) and be located in the same directory as your .EXE (this means that libraries - .dlls - use settings from the .exe that loads them), or use Web.config for ASP.NET applications and be located in the virtual host root (/), in the web application's root (/myapp, for example, which inherit settings from the virtual host's root Web.config), or in a sub-directory of your application (also named Web.config, but can only override some sections like <authorization> .
All .config files inherit settings from machine.config that is in the config sub-directory of your Framework installation for whichever version the application has loaded (or is loaded into).
You can find more about this from the link above.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I recently did this, and you should note that it may not be enough to have type="System.Configuration.NameValueSectionHandler,System" . With multiple versions of .NET installed, I found it to be necessary to expand this to include the strong version information, i.e. "System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" .
my blog
|
|
|
|
|
In some cases, yes it is necessary, but in most cases - including this case (which I've used countless times, as well as defined my own section handlers) - you can specify a partial name depending on the runtime settings on your machine (so long as an assembly is resolvable using a partial name). For example, if your application was loaded into an AppDomain that loaded .NET 1.1, it would use System.dll as you've described above.
If the AppDomain were created under .NET 1.0, the partial name would match System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
In both cases, however, the runtime settings of your machine as well as enforcement of which runtime was loaded (using the <requiredRuntime> and <supportRuntime> runtime config elements) can change this behavior.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks, steve.
Norman Fung
|
|
|
|
|
Thanks. That's very informative and I think it might just do. Our license files look like:
hash=.....
x509path=.....
serial=....
module1=enable&expiry='1/10/2005'&cal=10
module2=disable
...
...
...
Instead, we could:
<configuration>
<configSections>
<section name="securityinfo" type="System.Configuration.NameValueSectionHandler, System" />
<section name="licenseinfo" type="System.Configuration.NameValueSectionHandler, System" />
</configSections>
<licenseinfo>
<add key="encrypedhash" value="........." />
<add key="x509path" value="..." />
</licenseinfo>
<licenseinfo>
<add key="serial" value="..." />
<add key="module1" value="enable&expiry='1/10/2005&cal=10" />
<add key="module2" value="disable" />
<add key="module3" value="disable" />
</licenseinfo>
</configuration>
In application startup sequence:
NameValueCollection securityinfo = ConfigurationSettings.GetConfig("securityinfo");
NameValueCollection licenseinfo = ConfigurationSettings.GetConfig("licenseinfo");
Certificate cert=loadVendorCert(securityinfo);
byte[] encrypedhash=loadLicenseSectionHash(securityinfo);
//decrypt "encryptedhash" with public key from "cert":
byte[] hash=getLicenseSectionHash(cert, encrypedhash);
//Compare hash:
if( !ValidateLicenseSection(hash, licenseinfo)) {
... app config/license section has been tampered with...
} else {
... the rest of the startup sequence ...
}
Any thoughts...?
Norman Fung
|
|
|
|
|
To what end? If you're trying to encrypt communication, simply install a SSL cert on the server with the "Server authentication" OID (from VeriSign[^], Thawte[^], or a handful of others) and encrypt HTTP over SSL (HTTPS). Done. ASP.NET honors this because the SSL handshaking happens before the HTTP protocol.
If you need a way to encrypt data, consider using what ASP.NET already exposes: read about the <machineKey> element, which is auto-generated by default in your machine.config file, and can be explicitly set in your machine.config file, your site Web.config (the one in the root, or /), and your application Web.config file.
For a simle way to generate validation (public) and decryption (private) keys, read How to create keys by using Visual C# .NET for use in Forms authentication[^].
Now, if neither of these scenarios work, then I would recommend you do what you're doing with a slight modification: group your sections together under a section group like so:
<configuration>
<configSections>
<sectionGroup name="mycompany">
<section name="securityInfo" type="System.Configuration.NameValueSectionHandler, System" />
<section name="licenseInfo" type="System.Configuration.NameValueSectionHandler, System" />
</sectionGroup>
</configSections>
<!-- other stuff -->
<mycompany>
<securityInfo>...</securityInfo>
<licenseInfo>...</licenseInfo>
</mycompany>
</configuration> Make sure to change ConfigurationSettings.GetConfig("securityInfo") to ConfigurationSettings.GetConfig("mycompany/securityInfo") , for example.
This helps group related sections together so as not to be confused with others, or just to form a better hierarchy of settings. For example, the <system.web> element is another section group with child elements handled by lots of different section handlers.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
No, not SSL. The intended application is to generate application config files with licensing options and sign them. First you hash the licenseinfo section, then you use your private key to encrypt the hash. The encrypted hash would then become another key/value pair in securityinfo section of the generated application config file to be installed on client's machine.
Clients are given:
1. The application, the dlls and stuff
2. Generated application config file
3. Vendor certificate
On client side, application uses public key (from vendor certificate) to decrypt the hash - which is used to compare with hash computed on licenseinfo section to see if the settings has been tampered with... just dont fall asleep on me yet
Norman Fung
|
|
|
|
|
With specifics, I only offered suggestions for different scenarios.
If all you're looking to do is sign the .config file - an XML file - you might want ot take a look at my article, Using XML Digital Signatures for Application Licensing[^], which discusses the industry-support WS-Signature specification, support for which is in the .NET base class libraries (BCL).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks Heath, I just got a printed copy of your article so I can go over it the old fashion way when I take subway tonight.
Norman Fung
|
|
|
|
|
Hello,
I am having a little trouble with using the windows forms datagrid control. In my program, I need to give the user the ability to select and unselect multiple rows in the datagrid and then perform some action on those selected rows.
Initially, I was hoping to use checkboxes. I made a bool column in my database and added a checkbox column in my datagrid. This appeared to work okay. When I wanted to determine the selected rows, I just iterated through my data table and looked at the value of the column that was bound to the checkbox column. However, I soon found a problem with this approach. I have a "Select" menu, with different options that select thousands of rows in the datagrid (such as select all, select none, etc.) In order to do this, I needed to change the value of many checkboxes at once, and this is very very slow because I am having to edit each row in the corresponding datatable.
I've been trying to figure out other ways to get the same functionality, and I thought that maybe I could just use the built-in select in the datagrid (highlighting the entire row). I was able to select large numbers of rows much more quickly this way because I wasn't modifying any data in the datatable. However, now I have another problem. I don't know how to relate a row in the datagrid to the correct row in the datatable. I've found some code examples such as this:
BindingManagerBase bm = dataGrid1.BindingContext[dataGrid1.DataSource,dataGrid1.DataMember];
DataRow dr = ((DataRowView)bm.Current).Row;
But, this only works for the current row. What if I have a list of the row indexes in the datagrid, and I want to iterate through that list and perform actions on the correct row in the datatable?
Also, I really prefer the checkboxes over the highlighted rows. Is there a way that I can implement checkboxes without having to make a column in my datatable?
Any ideas would be great!
Thanks,
Blake
|
|
|
|
|