|
Where is label1 used here?
|
|
|
|
|
Given below is is my implementation, where should i add [Browsable(false)] or [Browsable(true)]
PropertyGrid pgGrid = new PropertyGrid();
pgGrid.CommandsVisibleIfAvailable = true;
pgGrid.Height = 400;
pgGrid.Width = 250;
pgGrid.Location = new Point(this.Width - (pgGrid.Width + 10), 0);
pgGrid.Dock = DockStyle.Fill;
this.Controls.Add(pgGrid);
pgGrid.Visible = true;
pgGrid.SelectedObject = label1; <--- here!
|
|
|
|
|
Hi,
first forgive my poor english
my problem is :
I made a solution with 2 runing projects, vb and C#.
The VB project contains a form with a Label.
The C# project contains a form with a Button.
The goal is to change the Label.Text in the VB project by pressing the C# Button.
I made a referance in the C# project to the VB Project.
But the only way I know in order to address the Label is by using
in the vb:
inside form1....
Public Function Fnc_ChangeTxt()
Label1.Text = "blabla"
End Function
and in the cs:
when pressing the button...
ProjectVB.Form1 f1 = new ProjectVB.Form1;
f1.Fnc_ChangeTxt;
I guess since im using "new" it wont address the current working VB project
what do i need to do ?
thanks in advance.
|
|
|
|
|
First of all, your English isn't all that bad!
I'm taking a stab at this, do you want to modify the label directly instead of using a function?
First thing to do is, ensure that the label is publicly accessible by setting it's Modifiers property to Public.
This property is "Private" by default.
Let us know if that helped!
|
|
|
|
|
hi, thanks for replying
It wont work.
when trying my code or your suggestion
it will go through all the steps ahowing as if all is ok
but in the form itself nothing will change.
I think its because im using:
ProjectVB.Form1 f1 = <big>new </big>ProjectVB.Form1;
and it causes a whole new instance of the form to be adressed.... or smth like that ^^
do you know of an other way to adress the vb form from the c# ?
|
|
|
|
|
I created the project on my side and it works just fine, here's my code:
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VBApplication;
namespace CSApplication1 {
public partial class Form1 : Form {
public VBForm1 vbf;
public Form1() {
InitializeComponent();
vbf = new VBForm1();
vbf.Show();
}
private void button1_Click(object sender, EventArgs e) {
vbf.Label1.Text = "Hello World!";
}
}
}
VB
No code on the VB side, I only added a label on the form and changed it's Modifiers to Public.
modified on Wednesday, December 23, 2009 5:56 AM
|
|
|
|
|
I think this is idd your problem. You'll need to fetch the instance already open.
Easier would be that your C# loads up, creates the VB Form for you and shows it. That way your variable has been set up in the C# project and is immediately accessible.
Hope this helps.
IOW
ProjectVB.Form1 f1 = new ProjectVB.Form1;
f1.ShowDialog();
f1.ChangeLblFunction();
|
|
|
|
|
Yes, the "new" is causing your problem, since it create a new instance of the VB form.
One of your two projects will be the Startup Project. In that you will be creating an instance of the other - or it wouldn't be displayed. Whereever you create and display the other form, save it and you can access it later.
So, if your startup project is C#, somewhere you will be saying:
ProjectVB.Form1 f1 = new ProjectVB.Form1;
f1.Show();
You can save the value as a class variable, and then call the Fnc_ChangeTxt method in your button handler.
If your startup project is VB, there will be similar code to show the C# form - You can hand it the instance of your VB form and store that as a C# class variable.
The better way to do it would require changes in the same area - create an event in the C# which you throw in your button event, and subscribe to in your VB form. This means that the two projects are more independant of each other.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
In your C# app, do something like this:
public partial class MyForm
{
private VBFormProject.VBForm m_vbForm = null;
private void clickHandler(object sender, EventArgs e)
{
if (m_vbForm == null)
{
m_vbForm = new VBFormProject.VBForm();
}
m_vbForm.Show();
m_vbForm.Fnc_ChangeText("some text");
}
private void OnClosing()
{
if (m_vbForm != null)
{
m_vbForm.Close();
}
}
}
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Every EventLog entry my application makes ends with the following string:
"For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp."
I know there is a way of removing or replacing this, I just can't seem to find it!
Regards!
|
|
|
|
|
Hi, someone knows a program to calculate the polynomial for CRC value?
I have the string example "100140590201004d000b00014b2b877053b17ee9100305ee5a" and the, i think, CRC value "7579d418" but i don't know the CRC polynomial.
I wait for suggestions.
Best regards and merry Christmas.
Andrea
|
|
|
|
|
|
Hi,
kindly let me know that, how may I change following datagridview font and size setting? coz, following commands are not working:
dataGridView1.Font.Name = "Vardana";
dataGridView1.Font.Size = 10;
thank you in advance
(Riaz)
|
|
|
|
|
You cannot modify the font's type since it is ReadOnly, you should replace it with a new font.
A simple way to change the Font:
dataGridView1.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular);
If you MUST use Verdana, you need to get a reference to it's FontFamily first, this is a little more code:
FontFamily[] ff = System.Drawing.FontFamily.Families;
FontFamily myFF = null;
foreach (FontFamily f in ff) {
if (f.Name == "Verdana") {
myFF = f;
break;
}
}
dataGridView1.Font = new Font(myFF, 10, FontStyle.Regular);
PS. I believe there are better ways to get to the FontFamily, perhaps using LINQ, anyone here may improve on this.
Merry Christmas
|
|
|
|
|
Hi,
we build a kernel mode dll which we want to access via C#! The kernel mode dll is called "sample.sys" and is an export driver. I tried to access the export (functions) with the dllimport statement from C#.
[DllImport("Sample.sys",
CharSet = CharSet.Auto,
CallingConvention = CallingConvention.Winapi)]
public static extern uint FindAll();
The definition from the dll and the function in the testing project ("FindAll") are the same. I also tried with the complete path to the export driver. The "Sample.sys" is located in the running directory of the C# testing assembly.
I always get a AccessViolationException ("attempt to read or write protected memory")
Does anybody know how to access this functions from C#?
|
|
|
|
|
This may be so obvious as to be a dumb question, but are you running this test under an Administrator or System account? Kernel mode functions, and the memory they use, are carefully protected from users, for good reason.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I run it as local Administrator
|
|
|
|
|
i hv problems below:
a = 123456.789
b = 7
c = a/b --> the result is 17636.6841
but i want it shows 17636 (not rounding to 17637)
can anyone helps???
thx,
cool-a
|
|
|
|
|
There are a lot of solutions to your problem, but you didn't tell us whether or not you're displaying the number, or merely want to omit the fractional part from further calculations. Assuming you just want to display, it, do it this way:
string cString = Convert.ToInt32(c).ToString();
If you want to change the actual value, you can use Math.Floor, or even Convert.ToInt32 (I think).
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Review the "Math" library. There is a "Floor" and "Ceiling" function. Ceiling rounds 1.1 to 2 and Floor makes 1.9 to 1.
You will need to make sure a and b are "double" but will be fine.
double a = 123456.789;
double b = 7;
double c = Math.Floor(a/b);
|
|
|
|
|
thx all... it helps me lot
|
|
|
|
|
When the CheckedChanged event fires, why does e not have a property with the current state? A CheckedListbox does...
Am I missing something here?
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)...
>>e has 'currentValue' and 'newValue'<<
private void checkBox1_CheckedChanged(object sender, EventArgs e)...
>>e has doesn't<<
Do I really have to go get the state from the checkbox when I'm already in the state event fired by that checkbox?
(checkBox1 == true)
That seems redundant. Thanks.
|
|
|
|
|
BDJones wrote: Do I really have to go get the state from the checkbox
yes
BDJones wrote: if (checkBox1 == true) ...
no
if (checkBox1.Checked) ...
|
|
|
|
|
|
The reason the checkedlistbox passes the state is because there are any number of individual checkboxes which may be checked/unchecked. A single checkbox is passed to you in the event
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkBox = (CheckBox)sender;
if(chkBox.Checked) ...
}
|
|
|
|