|
Luc is right.
Try something like this
using System;
using System.Windows.Forms;
namespace DelegateForm
{
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void TestDelegate() {
System.Threading.Thread.Sleep(1000);
OnAdd2List myDelegate;
myDelegate = new OnAdd2List(Add2List);
myDelegate(DateTime.Now.ToString());
}
private void Add2List(string s) {
AddItem(s);
}
private delegate void OnAdd2List(string s);
private void button1_Click(object sender, EventArgs e) {
this._thread = new System.Threading.Thread(new System.Threading.ThreadStart(TestDelegate));
this._thread.Start();
}
private void button2_Click(object sender, EventArgs e) {
}
private delegate void delAddItem(string item);
private void AddItem(string item){
if (listView1.InvokeRequired){
delAddItem del = new delAddItem(AddItem);
this.invoke(del, item);
}
else{
listView1.Items.Add(item);
}
}
private System.Threading.Thread _thread;
}
}
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
I need to use the Unicode version of the following:
DirectoryInfo currentDir = new DirectoryInfo(newDir);
I am trying to grab the Security descriptors from every directory but on directories over 260 characters it errors out. I am utilizing the following Pinvoke and adding on "\\?\" to each UNC path given to the above DirectoryInfo class, but it doesnt work, it just says "illegal character in path":
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern int DirectoryInfo(string newDir);
Can someone show me how this can be done for the above line?
Thanks
|
|
|
|
|
no one has any insight into this?
|
|
|
|
|
Hi Team,
Requrired functionality is that, I have to build a product based c# assembly with implementation of license funcionality.
Any body help me out from this scenario.
Regards
Tarun Singh
Sr. Software Engineer.
mailto:tksingh@zenta.com
|
|
|
|
|
I would change your job title if that is your question.
There are a lot of approaches to the problem and each approach is dependent on your individual business requirements. The most simplistic approach is an algorithm that can create keys that match a detectable pattern that will unlock features. Secure key fob is probably the most sophisticated. And internet registration, dll exchange is probably a nice in-between.
|
|
|
|
|
Could it be possible for a 15 days trial, so that while reinstalled it will not work.
Regards
Tarun Singh
Sr. Software Engineer.
mailto:tksingh@zenta.com
|
|
|
|
|
Hi all, please take a look at the screenshot below :
http://i.imagehost.org/0954/picture1_6.jpg
Sorry, the red line is for privacy.
As you can see, the groupBox is "above" the grid.
How to set the groupBox so the grid is above it?
I had tried bringToFront from the grid but failed.
Please take a look at my code below :
private void InitializeTab()
{
int intJmlChannel = Convert.ToInt32(channel.DefaultPersister.CountChannel());
intChannelth = 1;
myTabs = new TabPage[intJmlChannel];
GroupBox[] myGroupBox = new GroupBox[intJmlChannel];
Label[] myLabelMsisdn = new Label[intJmlChannel];
Label[] myLabelPort = new Label[intJmlChannel];
List<channel> listChannel = channel.DefaultPersister.ListAll().ToList();
myGrid = new iGrid[intJmlChannel];
for (int i = 1; i <= intJmlChannel; i++)
{
myGrid[i-1] = new iGrid();
myGrid[i-1].BorderStyle = iGBorderStyle.Flat;
myGrid[i-1].DefaultCol.CellStyle = iGrid1DefaultCellStyle;
myGrid[i-1].DefaultCol.ColHdrStyle = iGrid1DefaultColHdrStyle;
myGrid[i-1].Dock = DockStyle.Fill;
myGrid[i-1].ForeColor = SystemColors.WindowText;
myGrid[i-1].Header.Height = 19;
myGrid[i-1].Location = new Point(0, 0);
myGrid[i-1].RowTextCol.CellStyle = iGrid1RowTextColCellStyle;
myGrid[i-1].Size = new Size(902, 458);
myGrid[i-1].TabIndex = 0;
myGrid[i-1].TreeCol = null;
myGrid[i-1].TreeLines.Color = SystemColors.WindowText;
myGrid[i-1].BackColorEvenRows = Color.PaleTurquoise;
myGrid[i - 1].ReadOnly = true;
myTabs[i - 1] = new TabPage(listChannel[i - 1].MsisdnChannel);
myTabs[i - 1].Name = listChannel[i-1].MsisdnChannel;
if (listChannel[i - 1].SubDealer == 5)
{
myTabs[i - 1].BackColor = Color.Pink;
myTabs[i - 1].ForeColor = Color.Blue;
}
myGroupBox[i-1] = new GroupBox();
myGroupBox[i - 1].Dock = DockStyle.Bottom;
myGroupBox[i - 1].TabIndex = 1;
myGroupBox[i - 1].TabStop = false;
myGroupBox[i-1].Location = new Point(0, 367);
myGroupBox[i-1].Size = new Size(902, 91);
myTabs[i - 1].Controls.Add(myGroupBox[i - 1]);
myLabelMsisdn[i - 1] = new Label();
myLabelMsisdn[i - 1].AutoSize = true;
myLabelMsisdn[i - 1].Text = "Port : " + listChannel[i-1].PortNumber;
myLabelMsisdn[i - 1].Location = new Point(7, 20);
myLabelMsisdn[i-1].Size = new Size(35, 13);
myLabelMsisdn[i-1].TabIndex = 0;
myLabelPort[i-1] = new Label();
myLabelPort[i-1].AutoSize = true;
myLabelPort[i-1].Location = new Point(7, 44);
myLabelPort[i-1].Size = new Size(35, 13);
myLabelPort[i-1].TabIndex = 1;
myLabelPort[i - 1].Text = "Sub Dealer : " + listChannel[i-1].SubDealer;
myGroupBox[i-1].Controls.Add(myLabelMsisdn[i-1]);
myGroupBox[i - 1].Controls.Add(myLabelPort[i - 1]);
myTabs[i-1].Controls.Add(myGrid[i-1]);
tabControl.Pages.Add(myTabs[i-1]);
}
}
Above code is to create the control needed at runtime.
|
|
|
|
|
And the question is?
Please describe the problem and share what you have tried so far. Also, you need to fix the link in your post.
|
|
|
|
|
Thank you d@nish for the reply.
Yes, i just tried how to put link to my screenshot since it was the first time for me.
|
|
|
|
|
You did not make clear what you want, and the image is not really helping in probing your mind.
In your code I see a TabPage with a GroupBox and an iGrid added to it, both docked to the bottom or more. So they are bound to overlap.
There are many ways to make them not overlap, pick one:
1. make the iGrid anchored all around but leave sufficient bottom for the GroupBox;
2. add the iGrid to the GroupBox, GroupBox docked fill, iGrid anchored all around.
3. use a SplitContainer (is overkill IMO)
4. use a TableLayoutPanel; you might add the two labels and one iGrid directly to it.
|
|
|
|
|
Thank you Luc for the reply.
Luc Pattyn wrote: You did not make clear what you want, and the image is not really helping in probing your mind.
Yes, sorry for that. Maybe i should explain the image. On the image, there's an arrow point to a row in the grid. As we can see, the groupBox is "above" the grid. Also we can see that the groupBox is hiding the grid scrollBar. What i want is the rows in the grid can be seen all until the last row but the groupBox still on below position of the form.
I had pick your suggestion no. 1 and it didn't work.
For your suggestion no. 2, i don't want the grid inside the groupBox ( i want them to be separated ).
Suggestion no. 3 and 4 not tried yet.
|
|
|
|
|
Endien wrote: I had pick your suggestion no. 1 and it didn't work.
So you did it wrong; of course it can be made to work. And there are many more ways to get what you want, based on location/size/bounds properties and events.
|
|
|
|
|
The best solution is using Luc suggestion number 4. Using TableLayoutPanel.
I will share the code in a few minutes.
|
|
|
|
|
private void InitializeTab()
{
int intJmlChannel = Convert.ToInt32(channel.DefaultPersister.CountChannel());
intChannelth = 1;
myTabs = new TabPage[intJmlChannel];
GroupBox[] myGroupBox = new GroupBox[intJmlChannel];
Label[] myLabelMsisdn = new Label[intJmlChannel];
Label[] myLabelPort = new Label[intJmlChannel];
TableLayoutPanel[] tbl = new TableLayoutPanel[intJmlChannel];
List<channel> listChannel = channel.DefaultPersister.ListAll().ToList();
myGrid = new iGrid[intJmlChannel];
for (int i = 1; i <= intJmlChannel; i++)
{
tbl[i-1] = new TableLayoutPanel();
tbl[i - 1].RowCount = 2;
tbl[i - 1].ColumnCount = 1;
tbl[i - 1].Dock = DockStyle.Fill;
myGrid[i-1] = new iGrid();
myGrid[i-1].BorderStyle = iGBorderStyle.Flat;
myGrid[i-1].DefaultCol.CellStyle = iGrid1DefaultCellStyle;
myGrid[i-1].DefaultCol.ColHdrStyle = iGrid1DefaultColHdrStyle;
myGrid[i-1].Dock = DockStyle.Fill;
myGrid[i-1].ForeColor = SystemColors.WindowText;
myGrid[i-1].Header.Height = 19;
myGrid[i-1].RowTextCol.CellStyle = iGrid1RowTextColCellStyle;
myGrid[i-1].Size = new Size(902, 458);
myGrid[i-1].TabIndex = 0;
myGrid[i-1].TreeCol = null;
myGrid[i-1].TreeLines.Color = SystemColors.WindowText;
myGrid[i-1].BackColorEvenRows = Color.PaleTurquoise;
myGrid[i - 1].ReadOnly = true;
myTabs[i - 1] = new TabPage(listChannel[i - 1].MsisdnChannel);
myTabs[i - 1].Name = listChannel[i-1].MsisdnChannel;
if (listChannel[i - 1].SubDealer == 5)
{
myTabs[i - 1].BackColor = Color.Pink;
myTabs[i - 1].ForeColor = Color.Blue;
}
myGroupBox[i-1] = new GroupBox();
myGroupBox[i - 1].TabIndex = 1;
myGroupBox[i - 1].TabStop = false;
myGroupBox[i - 1].Dock = DockStyle.Fill;
myGroupBox[i-1].Size = new Size(902, 91);
myLabelMsisdn[i - 1] = new Label();
myLabelMsisdn[i - 1].AutoSize = true;
myLabelMsisdn[i - 1].Text = "Port : " + listChannel[i-1].PortNumber;
myLabelMsisdn[i - 1].Location = new Point(7, 20);
myLabelMsisdn[i-1].Size = new Size(35, 13);
myLabelMsisdn[i-1].TabIndex = 0;
myLabelPort[i-1] = new Label();
myLabelPort[i-1].AutoSize = true;
myLabelPort[i-1].Location = new Point(7, 44);
myLabelPort[i-1].Size = new Size(35, 13);
myLabelPort[i-1].TabIndex = 1;
myLabelPort[i - 1].Text = "Sub Dealer : " + listChannel[i-1].SubDealer;
myGroupBox[i-1].Controls.Add(myLabelMsisdn[i-1]);
myGroupBox[i - 1].Controls.Add(myLabelPort[i - 1]);
tbl[i-1].Controls.Add(myGrid[i-1],0,0);
tbl[i-1].Controls.Add(myGroupBox[i-1],0,1);
tbl[i - 1].RowStyles.Add(new RowStyle(SizeType.Percent, 85F));
tbl[i - 1].RowStyles.Add(new RowStyle(SizeType.Percent, 15F));
tbl[i - 1].RowStyles[1].SizeType = SizeType.Percent;
tbl[i - 1].RowStyles[1].Height = 15;
myTabs[i-1].Controls.Add(tbl[i-1]);
tabControl.Pages.Add(myTabs[i-1]);
}
}
The screenshot : http://h.imagehost.org/0646/picture2.jpg
Thank you Luc for suggestion no. 4
|
|
|
|
|
Hello,
I have a project which has Excel object reference to object library 5.0. I want to install the project on some other comp.What files will I have to zip alongwith my .exe file
I am working on Windows XP and the client is on Windows 2000. Will that make any difference.
Is there any site which can help me in installation and guide me through versions of Excel and how to handle version differnces.
Pritha
|
|
|
|
|
prithaa wrote: What files will I have to zip alongwith my .exe file
I guess you will have to add redistributable PIA[^] to your set up.
prithaa wrote: Is there any site which can help me in installation and guide me through versions of Excel and how to handle version differnces.
You can use late binding here. This[^] article would help understanding it.
|
|
|
|
|
I need to make a call to a third party Java API made up of Java classes. Is that possible with C#, or do I need an interface written as a web service to do the translations on both sides?
|
|
|
|
|
1. The easiest way would be to have web service.
2. You can make use of JNBridge[^].
|
|
|
|
|
hello,
I'd like my program to detect when another user is watching/controlling the machine the program is running on. I tought I could check this by doing a WTSRegisterSessionNotification and then checking the WM_WTSSESSION_CHANGE messages, but unfortunately they don't seem to fire when a remote user logs on with RA.
thanks,
Gert
|
|
|
|
|
|
Furthermore, some Remote Assistance programs like VNC, TeamViewer, NetViewer etc. do so without a formal log-on procedure, from the point of view of windows the other user is not logged on.
You would have to watch the processes on that machine, perhaps using WMI; maybe you could then get an event when such a program is started.
|
|
|
|
|
Just to clarify: I do mean detecting Microsofts Remote Assistance feature.
Your suggestion does work for XP as the process rdsaddin.exe appears when RA is active. It doesn't work on Vista (and I suppose Windows 7) though as no extra processes are created on Vista when an RA connection is set up...
|
|
|
|
|
Hi, I have got a strange problem when using a AxHost wrapped activex control.
We normally access this control from multiple c# threads, and have never had a problem with this until now. But after adding a manifest file to the .exe in order to enable reg-free COM (so we don't have to register the activeX control on customer machines), the control will now crash when accessed from any background thread as long as it is not registered on the current machine. If it is registered then it can be used from multiple threads just fine.
Any help would be appreciated as this is a very strange problem, perhaps I am missing something from the manifest file?
The manifest file contains a "file" entry which points to the relevent .ocx file, with a "comClass" subitem, with "clsid" set as required and "threadingModel" set to "Apartment" (changing the threading model doesn't seem to have any affect on this behaviour).
For example:
public Form1()
{
InitializeComponent();
control = new AxLib.AxControl();
control.Dock = DockStyle.Fill;
this.Controls.Add(control);
control.CreateControl();
}
private void Form1_Load(object sender, EventArgs e)
{
control.DoSomething();
myThread = new Thread(myThread_ThreadStart);
myThread.Start();
}
void myThread_ThreadStart(object arg)
{
control.DoSomething();
}
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:21am.
|
|
|
|
|
This doesn't seem to apply to methods called from the actual activeX (COM) object - we make calls on the activeX object all over the place on background threads.
Its only if the control is unregistered (so loading locally through the manifest) that we encounter problems.
|
|
|
|