|
I have consulted google and I've reviewed the projects on the site but unfortunately I'm not sure how to integrate those tutorials into what I'm trying to do here. I basically need to call a function and return it's value to my program. And I also need to be able to modify it's value.
|
|
|
|
|
Nokoff wrote: I basically need to call a function and return it's value to my program. And I also need to be able to modify it's value.
You can write a webservice with 2 methods. A GetValue method and a SetValue method. You will be able to call these functions in your app to read a value and set a value.
It's just an idea.
Hope it helps.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Hello All,
I have a datagrid view on a windows form that I have working pretty well. I did not have the "MultiSelect" set to true so naturally the user was only able to make one row selection at a time and this worked fine.
Now the users have come up with a solution to trim their work time by being able to select multiple rows and have the processing done on the rows selected.
Here is my problem. I know how to retrieve the value in the first cell of the selected row but how do I go about selecting the values from the first cell in the subsequent rows that have been selected. I thought of using a 'for' statement but I am not sure how to move to the next row to retrieve the value of the next cell.
Thank you in advance for any help provided.
|
|
|
|
|
In general, things with a SelectedItems property can just be used like an array. So to get the first selected row, you just use
SelctedItems[0]
and for the second
SelectedItems[1]
etc. Im not sure if its called SelectedItems in a datagrid but it should work the same. I could be mistaken. If you've not got an answer by the time i get home, i'll check it out.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
The SelectedRows property gives you an DataGridViewSelectedRowCollection on which you can iterate.
Hope it helps
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Andrei,
I am sorry to be so bold as to state that I am not sure how I would implement the collection to iterate through. I am quite new to C# and coming from VB, collections are a different breed (for me at least.) I haven't gotten that far yet. Could you find yourself to provide a very small example of how to implement this particular collection. I did look to see if the SelectedRows Property included the Collection but couldn't find it. I did see something about GetEnumerator but I'm lost.
Thanks though.
F
|
|
|
|
|
I will give you an example, supposing you have a DataGridView called dgv
DataGridViewSelectedRowCollection collection = dgv.SelectedRows;
foreach (DataGridViewRow row in collection)
{
}
row is a DataGridViewRow with which you have work before...right? Of course you will have to place this code somewhere in an event, or function...you'll figure that part out.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Andrei,
That was the ticket. After your response I researched it and now I have a good understanding of how this works. Again, thank you both for your responses.
Best regard,
F
|
|
|
|
|
Hi,
Consider the next situation
I Have this Attribute
<br />
[AttributeUsage(BlaBlaBla)]<br />
public class myattribute:Attribute<br />
{<br />
...<br />
...<br />
...<br />
}<br />
Now - Inside My Form
<br />
public class MyForm:Form<br />
{<br />
[myattribute]<br />
Button button1;<br />
<br />
Public MyForm()<br />
{<br />
button1 = new Button();<br />
}<br />
}<br />
now - using reflection - how can i get this attribute from button1?
the next gode does not work
<br />
Type Y = button1.GetType();<br />
object[] obj = T.GetCustomAttributes(typeof(myattribute),false);<br />
obj.Length is 0
(I Guess it because T.GetCustomAttributes returns the attributes of Type Button and not of its instance button1)
so... how can i get this attribute from button1?
Thanks
|
|
|
|
|
It's not working because your code is asking for all custom attributes on the Button class, not on your button1 field.
Here's how you should get custom attributes from a field:
Type myFormType = typeof(MyForm);
FieldInfo button1Field = myFormType.GetField("button1", BindingFlags.NonPublic | BindingFlags.Instance);
object[] customAttributes = button1Field.GetCustomAttributes(typeof(myattribute), false);
|
|
|
|
|
|
Rather than looking at the class, you have to look at the fields that belong to the class. Try this instead:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
namespace Test
{
[AttributeUsage(AttributeTargets.All)]
public class myattribute : Attribute
{
public myattribute() : base() { }
}
public partial class Form1 : Form
{
[myattribute]
Button b1;
public Form1()
{
b1 = new Button();
this.Controls.Add(b1);
FieldInfo[] fis = this.GetType().GetFields(
BindingFlags.Instance | BindingFlags.NonPublic |
BindingFlags.Public);
foreach (FieldInfo fi in fis)
{
object[] o = fi.GetCustomAttributes(typeof(myattribute), true);
if (o.Length != 0)
{
Console.WriteLine("Hello from o");
}
}
}
}
}
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
Can anyone help?
I want to be able to drag and drop text into a Rich Text Edit or Memo type component but I want to drop the text at the position of the mouse cursor when the mouse button is released?
I have read a few articles so I can do drag and drop but how to drop at the mouse cursor position?
Thanks In Advance
|
|
|
|
|
I would suggest utilising the MouseUp event handler, and use HitTestInfo to find the coordinates of the pointer...
HitTest(e.X,e.Y)
Then set the cursor to this position, then perform your drop method at that position
Hope this helps
Give me strength, give me caffeine
|
|
|
|
|
Hey people
Was just wondering whether anyone knew whether this if statement is gonna be system dependent or not
e.KeyChar == 13, where e is a KeyPressEventArgs
Am trying to allow a text box to perform an action when return is pressed
The method works on my comptuer, but will it on another keyboard?
Cheers
Give me strength, give me caffeine
|
|
|
|
|
It's not system dependent because if you look at ASCII Table you can see that it's a standard notation for CR.
c#_keithy wrote: e.KeyChar == 13
My recommendation is to use the Keys enumeration to compare with e.KeyChar
Hope it helps.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Just found an mdn article on using Keypress events, which uses the following compare statement
e.KeyChar == (char)Keys.Return
KeyPressArticle[^]
Thanks for your input
Give me strength, give me caffeine
|
|
|
|
|
Hi,
I am able to list all available providers in the system presently windows using c#.
I can do that with the wql query i.e. select * from __Provider. But if i want to determine what type of provider it is, like say an instance provider or method provider etc then how do I determine that?
Also different classes use different types of providers like classes with events use event providers and those with use of methods use method provider.
But how to determine which event or method provider etc is being used by the class?
|
|
|
|
|
First og all.....I'm a newbee.....!!!
I need to make a service, that on a given time executes an application (APPL_1).
Furthermore I need to be able to tell the service to execute APPL_1 manually from another og my C# applications (APPL_2) by clicking a button.
So what I need is a way to "communicate" between the service and APPL_2 in order to execute APPL_1.
I hope the above isn't to cryptic.. *ss*
All kind of "help" would be appriciated.
/Lars Lie
|
|
|
|
|
If you need to communicate between processes, you have several options.
Look up a technology called .NET remoting. It allows you to "communicate" with other processes. There are several articles and examples on this site.
There are plenty of other options too: web services (your service exists on the web, called by either other web applications or desktop applications), as well as the new Windows Communication Foundation technology (WCF). Any of those 3 should work for you.
|
|
|
|
|
Since there's no default method that let's me unhook all listeners from an event at once, I sometimes do this:
public event PropertyChangedEventHandler PropertyChanged;
public void UnHook()
{
if (this.PropertyChanged != null)
{
Delegate[] list = this.PropertyChanged.GetInvocationList();
foreach (Delegate d in list) this.PropertyChanged -= d as PropertyChangedEventHandler;
}
}
However, since I find it kind of annoying to write this code for different types of events I'd really like to be able to do something this:
public static void Unhook<T>(event x)
{
Delegate[] list = x.GetInvocationList();
foreach (Delegate d in list) x -= d as T;
}
My question: Does anyone know of a way to implement parsing of events as method arguments? Thanks in advance...
Standards are great! Everybody should have one!
|
|
|
|
|
Let me point you over towards EventPools[^]. They tackle the management of events in a different way.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Ok, that looks promising, thanks. Still I'm curious if it's in anyway possible to realize parsing of events as arguments...
Standards are great! Everybody should have one!
|
|
|
|
|
Great article. I'm going to explorer this idea some more for some UI stuff I'm currently working on.
|
|
|
|