|
That won't work because, as the original question mentioned, all controls are components but not vice versa (Control derives from Component). Components are not in a form's Control tree.
Josh
|
|
|
|
|
How about reflection then? You can do a GetMembers() on the form's Type and look for fields. See if that field type is an implementation of IComponent, and add it to the list.
List<IComponent> components = new List<IComponent>();
foreach (MemberInfo mi in this.GetType().GetMembers()) {
if (mi.MemberType == MemberTypes.Field) {
if (mi.DeclaringType.GetInterface("IComponent") != null) {
FieldInfo fi = mi as FieldInfo;
components.Add((IComponent)fi.GetValue(this));
}
}
}
I haven't tested this code, but it should be pretty close. Last modified: Wednesday, May 31, 2006 12:25:05 PM --
|
|
|
|
|
Hi Dustin
tnx for the reply, unfortunately it doesn't seem to work. Maybe i should dig in a little deeper, but i don't think this can work because imho components aren't fields . Tnx for the effort anyway.
Maybe i shoud try another approach. If I just could get the correct container from my component (ie. the form it's hosted on but then defined as container instead of form).
BTW: i'm still using .Net 1.1 and not 2.0, just to avoid confusion.
batmike2000
|
|
|
|
|
hi guys,
i've found the solution: i indeed needed to use reflection but on fieldinfo level
<br />
strFormName = param_Form.Name<br />
<br />
Dim param_Form_type As Type = param_Form.GetType()<br />
Dim compFields As FieldInfo() = param_Form_type.GetFields(BindingFlags.Instance Or BindingFlags.NonPublic)<br />
For Each fiField As FieldInfo In compFields<br />
Dim strCtrl(1) As String<br />
strCtrl = ReturnCompName(fiField, param_Form)<br />
For Each dr As DataRow In myrs.Rows<br />
If strCtrl(0) = dr("SecAuthCtrl_Name") And fiField.FieldType.FullName = dr("SecAuthCtrl_Type") Then<br />
Select Case fiField.FieldType.FullName.ToLower<br />
Case "System.Windows.Forms.ToolBarButton".ToLower<br />
Dim cmp As ToolBarButton = DirectCast(fiField.GetValue(param_Form), ToolBarButton)<br />
cmp.Enabled = dr("SecAuthorized_Enabled")<br />
cmp.Visible = dr("SecAuthorized_Visible")<br />
Case "System.Windows.Forms.MenuItem".ToLower<br />
Dim cmp As MenuItem = DirectCast(fiField.GetValue(param_Form), MenuItem)<br />
cmp.Enabled = dr("SecAuthorized_Enabled")<br />
cmp.Visible = dr("SecAuthorized_Visible")<br />
Case Else<br />
End Select<br />
End If<br />
Next<br />
Next
this works now,
tnx again for your effort
batmike2000
|
|
|
|
|
|
Hi,
My requirement is to set combobox column for deptno column of the table dept.
When insert button is clicked,i write the following code
DataGridViewComboBoxColumn cell = new DataGridViewComboBoxColumn();
cell.DataPropertyName = "DEPTNO";
cell.HeaderText = "dno";
cell.Items.Add(10);
cell.Items.Add(20);
cell.DataSource = ds.Tables["dept"];
cell.ValueMember = "DEPTNO";
cell.DisplayMember = "deptno";
dataGridView1.Columns.Add(cell);
dt=new DataTable();
dt = (DataTable)dataGridView1.DataSource;
DataRow dr = dt.NewRow();
dt.Rows.Add();
dataGridView1.DataSource = dt;
My problem is that combobox column is displayed as a separate column.But it value member set to deptno column of dept table.And when i select 30 from that combo box control goes to deptno=30 row.
I want combox cell is set for deptno column and when we select a value from that combo box column the velue is displayed for that row.
How to do this.
Thanks in advance.
|
|
|
|
|
The DTE object is the Development Envirnoment object for VS.
But, I can't create it.
Has anyone changed it so they can use it?
If so, what exaclty did you change to get permissions?
Thanks,
Nick
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
I know the StatusBar does not have the backColor property associated with it so i was trying to change the colour through an API call. However my code does not seem to work even though many people have managed to do it. Am i doing something wrong here? Any help would be appreciated.
using System.Runtime.InteropServices;
[DllImport("User32.dll")]
public extern static void SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
public void ChangeStatusBarColour(System.Windows.Forms.StatusBar sbar, int color)
{
int CCM_FIRST = 0x2000;
int SB_SETBKCOLOR = (CCM_FIRST + 1);
SendMessage(sbar.Handle, SB_SETBKCOLOR, 0, color);
}
And in my derived StatusBar class i have this call to the previous object:
manipStatus.ChangeStatusBarColour(this, 10929647);
thanks in advance.
|
|
|
|
|
See this:
http://support.microsoft.com/default.aspx?id=319311
|
|
|
|
|
Ahhh Excellent, thanks. Not sure how i didnt come across it earlier
Darren
|
|
|
|
|
I use axWebBrowser, but i don't know how to do this.
Help me please.
|
|
|
|
|
What is the use of nGen(native Image Generator), How to Use it
Subbu
|
|
|
|
|
|
Hai All
I have created a custom menuitem in the tools Menu on click of which a windows form is launched that contains a simple textbox and ok Button.
This Custom menu will be available in .NET IDE . When i open a new project in the IDE and Click my Custom menu the above mentioned form will be opened . Now My requirement is that i shd get a .cs file added automatically to the solution of the currently working project om the click of the OK button....
Can u pls help me out
Pavithra
|
|
|
|
|
Just read all answers to your "SAME" question :
http://www.codeproject.com/script/comments/forums.asp?forumid=1649&mpp=50&select=1510871&df=100#xx1510871xx
http://www.codeproject.com/script/comments/forums.asp?forumid=1649&mpp=50&select=1510433&df=100&fr=51#xx1510433xx
|
|
|
|
|
Dear friends,
How can I find that a DLL file is a .NET Managed class library or a COM activex library.I have a DLL file and I wand to Register it if it was a COM unmanaged library.How can I recognize that ?
Best Regards,
[ _ Always there is another way _ ]
|
|
|
|
|
I guess the simplest (and least efficient) way would be to simply try loading the assembly using Assembly.Load[^] and handling the exception it throws if it's not a .NET dll.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanx Senthil...
That is a cool cheat.I found another way to recognize that but I think,your idea has less overhead and is a less time consuming task.You can see this methode here :
http://geekswithblogs.net Again thanx for your instant reply,
XironiX
[ _ Always there is another way _ ]
|
|
|
|
|
Hi All,
i am using cystel report viewer in our program.what i want is ,at run time when entries added to report viewer it will automatically scroll down as the entries added.ones page is finished it will move to another page. without click next button of reportviewer or press the scroll button to scroll down.
please help me out.
Amit Grover
CDAC R&D
|
|
|
|
|
i want to convert hexadecimal value to string...
can anybody give me a solution for it....using C#
|
|
|
|
|
i want to convert hexadecimal value to string...
can anybody give me a solution for it....
|
|
|
|
|
|
0x00BABE.ToString("X")
-- modified at 8:08 Wednesday 31st May, 2006
|
|
|
|
|
hi
i was opened a exe file binary and save it as Byte[] on disk.
i want to create blank process and inject byte[] to this process and restart process.
how to do that ??
|
|
|
|
|
Hackety hacketing?
-Larantz-
|
|
|
|