|
hi
i was add dataGridComboBoxColumn in my datagridview and write this code to bind it to my column :
this.personPropertiesTableAdapter.Fill(this.dataSet_AddressBook.PersonProperties);<br />
dataGridComboBoxColumn.DataSource = this.dataSet_AddressBook.PersonProperties;<br />
dataGridComboBoxColumn.ValueMember = "CategoryName";
but when i fill dataset, value don't show in dataGridComboBoxColumn and i must select dataGridComboBoxColumn and select that value from combo list,but i want when i fill dataset,value show on dataGridComboBoxColumn,but how to do ?
thanks
|
|
|
|
|
I design a class to DataGridViewComboBoxColumn and OTHERS
when u want to bind data , u use :
ClassLibrary_Pharm.Class_ComboBindData.u_ComboBindData(dataGridComboBoxColumn,"PersonProperties",SqlConnectionstring);
follow is my project code, u can modify it
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Data;
namespace ClassLibrary_Pharm
{
public static class Class_ComboBindData
{
public static bool u_ComboBindData(object combo, string sTopic)
{
return u_ComboBindData(combo, sTopic, null);
}
public static bool u_ComboBindData(object combo, string sTopic, EcareHis.C.Common.His_LogOn Logon)
{
bool blReturn = false;
DataSet ds = null;
switch (sTopic.ToLower().Trim())
{
case "sex":
ds = u_GetSexual();
break;
case "stay":
ds = u_GetStay();
break;
case "readyflag":
ds = u_GetConfect();
break;
case "department":
ds = u_GetDeptEmp(Logon,"epr");
break;
case "code213":
ds = u_GetCodeTable(Logon, "realhis","code213");
break;
case "code211":
ds = u_GetCodeTable(Logon, "realhis", "code211");
break;
case "code212":
ds = u_GetCodeTable(Logon, "realhis", "code212");
break;
}
if (ds == null) throw new Exception("not rows" + sTopic);
if (ds.Tables["param"].Rows.Count < 1) throw new Exception("row count < 1" + sTopic);
switch (combo.GetType().ToString())
{
case "System.Windows.Forms.ComboBox":
((ComboBox)combo).DataSource = ds.Tables["param"];
((ComboBox)combo).ValueMember = "value";
((ComboBox)combo).DisplayMember = "mark";
break;
case "System.Windows.Forms.DataGridViewComboBoxColumn":
((DataGridViewComboBoxColumn)combo).DataSource = ds.Tables["param"];
((DataGridViewComboBoxColumn)combo).ValueMember = "value";
((DataGridViewComboBoxColumn)combo).DisplayMember = "mark";
break;
default:
throw new Exception("ClassType is not Valid");
break;
}
blReturn = true;
return blReturn;
}
private static DataSet u_GetSexual()
{
DataSet ds = new DataSet();
DataTable newTable = new DataTable("param");
newTable.Columns.Add("mark", typeof(string));
newTable.Columns.Add("value", typeof(string));
DataRow dr = newTable.NewRow();
dr["mark"] = "M";
dr["value"] = "M";
newTable.Rows.Add(dr);
dr = newTable.NewRow();
dr["mark"] = "F";
dr["value"] = "F";
newTable.Rows.Add(dr);
ds.Tables.Add(newTable);
return ds;
}
private static DataSet u_GetStay()
{
DataSet ds = new DataSet();
DataTable newTable = new DataTable("param");
newTable.Columns.Add("mark", typeof(string));
newTable.Columns.Add("value", typeof(string));
DataRow dr = newTable.NewRow();
dr["mark"] = "outpatient list ";
dr["value"] = "O";
newTable.Rows.Add(dr);
dr = newTable.NewRow();
dr["mark"] = "inpatient list";
dr["value"] = "I";
newTable.Rows.Add(dr);
ds.Tables.Add(newTable);
return ds;
}
private static DataSet u_GetConfect()
{
DataSet ds = new DataSet();
DataTable newTable = new DataTable("param");
newTable.Columns.Add("mark", typeof(string));
newTable.Columns.Add("value", typeof(string));
DataRow dr = newTable.NewRow();
dr["mark"] = "Config";
dr["value"] = "0";
newTable.Rows.Add(dr);
dr = newTable.NewRow();
dr["mark"] = "Dont config";
dr["value"] = "1";
newTable.Rows.Add(dr);
ds.Tables.Add(newTable);
return ds;
}
private static DataSet u_GetDeptEmp(EcareHis.C.Common.His_LogOn Logon,string sDatabase)
{
DataSet ds;
try
{
string sSelectSql = "select 'mark'=name,'value'=empid from emp where deptid='" + Logon.LogDeptid + "' and useflag='Y'";
ds = Logon.u_SqlLocate(sSelectSql, "param", sDatabase);
}
catch (Exception e1)
{
throw new Exception(e1.Message);
}
return ds;
}
private static DataSet u_GetCodeTable(EcareHis.C.Common.His_LogOn Logon, string sDatabase,string stableName)
{
DataSet ds;
try
{
string sSelectSql = "select 'mark'=rtrim(remark),'value'=rtrim(code) from "+stableName;
ds = Logon.u_SqlLocate(sSelectSql, "param", sDatabase);
}
catch (Exception e1)
{
throw new Exception(e1.Message);
}
return ds;
}
}
}
Sorry ...
|
|
|
|
|
Hello,
I have a generic class BindingCollection<T> : IBindingList
The purpose of this class is to collect Business Objects and functionality around them (LoadAll, New ...). I implemented IBindingList so I could be able to bind it to a DataGridView (with BindingSource) and when changes occur to the BindingCollection, the DataGridView would notice and update itself and vice versa.
I think that so far, this is a logical setup, no?
Now I'm wondering how I should implement the IBindingList interface methods.
Should I make a class-variable BindingList<T> list and when, for example, AddIndex(...) is called, do something like
<br />
public void AddIndex(PropertyDescriptor property)<br />
{<br />
((IBindingList)list).AddIndex(property);<br />
}<br />
<br />
At the moment I implemented all interface methods in a similar way, but even though my inner list gets updated nicely, the DataGridView still doesn't notice any changes nor does it update it's presented data.
Any help would be very welcome, because I have been struggling with this problem for quite a while, and you could help me a lot further.
Greets, Bert
|
|
|
|
|
Hi,
have you bound the ListChanged event of the inner class? If not then do so and rethrow the event within your class.
Robert
|
|
|
|
|
Indexes you have to manage yourself (I looked into implementing the same thing), if you look at the source code in Reflector (if you can get your head around the way things have been implemented), then you'll see that (I think it was anyway) AddIndex will throw a NotImplemented exception.
You basically have to manage your own indexes, I seem to remember there was one method which you could override which would be fired when anything changed. Can't remember the name of it but if you want it I can dig it up tomorrow sometime when I put the other disk back in (and when I have time).
Possibly the simplest way to maintain indexes is to have a dictionary object to provide looking up the indexes. Maybe, I'm not sure though. There doesn't seem to be very much documentation on the subject at all.
Don't hesitate to ask if you want further help as I did spend quite a bit of time figuring out what was going on (just got to remember what it was ).
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
After importing an image into a C# windows based application, and changing the "Build Action" from the default of "Content" to "Embedded Resource", and attempting to overwrite the image file from outside the application as a windows operation, the image replacement does not appear to be re-embedded as a resource thereby replacing the original image. Is the reason because the image file is embedded at the time that the application is compiled as a build? Is there some way that the new image file could be programmatically re-embedded as a resource through the manipulation of an image file property from inside the application?
Would really appreciate some insights as to the correct approach. The idea of embedding the image file as a resource is a good one, but I would like to be able to dynamically overwrite that image file and to re-embed it at run-time.
Also, it appears that the path to the image file when importing it into an application is unable to be modified from the default path of "C:/Documents and Settings/Administrator/My Documents/Visual Studio Projects/". Granted, this path can be set in the "Tools > Options > Environment > Projects and Solutions" settings section. However, can this default path be changed to a different directory for just the image files or is it locked in place with respect to the entire application's directory location? If the directory path cannot be modified, then I believe that it would really limit the placement for these image files in the application.
I suspect that the image file is embedded in binary format, but this should be able to be done dynamically on the fly. Any ideas or suggestions would be appreciated.
|
|
|
|
|
Importing an image (or any resource) in the manner you describe embeds the resource at compile time into the resulting binary. The only way to change the embedded resource is to recompile the application. The only way to do this programmatically at run-time would be to use CodeDom and reflection to emit a new DLL that contains the updated image.
Why would you want to be able to change this at runtime? Typically, if you are embedding a resource like this it is to prevent the end-user from changing it. One solution would be to check if an "override" file is found (a file with a specific name and directory location, and possibly other specifications as well) and, if so, use that override file; otherwise the embedded image would be used.
I'm not sure about the path issue you mention...someone else will need to comment on that one.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
One thing you can do if you want to be able to change your embedded image, is put resources in a dll, which you can then recompile and drop in to your projec.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I've designed a udp connection using socket and threading. I want to know how I can change sound to an array of byte and change an array of byte to sound. So how can I set received sound to speaker and give output sound from its device like microphone?
What should I do?
Thanks a lot for your answers.
Bahman
|
|
|
|
|
Hi,
I have a partial answer to your question:
store the sound data in a byte array, pin it in memory, and call the unmanaged function
[DllImport("Winmm.dll", CallingConvention=CallingConvention.Cdecl)]
static extern int sndPlaySound(IntPtr buffer, int dwFlags);
with flag value = 4 (= SND_MEMORY)
More on this in http://www.bobpowell.net/playsnd.htm[^]
Dont know about capturing sounds though.
Luc Pattyn
|
|
|
|
|
I am trying use the IR on a PDA to communicate to another source. I am successful in finding out either the DeviceID and Device Name. I can also connect using irClient.Connect(irEndP);
My problem is either declaring the Stream or the WriteByte. My code is
irEndP =
new IrDAEndPoint(irDevices[0].DeviceID, irServiceName);
irClient = new IrDAClient();
irClient.Connect(irEndP);
Stream baseStream = irClient.GetStream();
System.Text.ASCIIEncoding encoding = new
System.Text.ASCIIEncoding();
string Name = "Hello World\n";
int strlen = Name.Length;
byte[] buffer = new byte[buffersize];
buffer = encoding.GetBytes(Name);
if (baseStream.CanWrite)
{
//baseStream.WriteTimeout = 1000;
baseStream.Write(buffer, 0, 5);
baseStream.Close();
}
I have tried baseStream.Flush(); and it does not help.
Help Please!
|
|
|
|
|
Is there any way to permanently set a window to the bottom of the stack?
I know you can send it to the back using:
void setbottom(ref Window window)
{
IntPtr hWnd = new WindowInteropHelper(window).Handle;
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
}
However that method needs to be called every time something else goes to the back. So is there any way make a window permanently set to the back?
- Munty
|
|
|
|
|
I seriously doubt that you could. What would happen if you had two applications that tried to do this?
Why would you want to do this?
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
It's an alternate desktop. (Most normal windows functions are gone, and some specific functions are included)
As for what happens when two programs do this, I'd assume that the first program to do it would have priority.
After some digging around on my own, in microsofts MSDN website, there's apparently a AlwaysOnBottom setting in Object, but it seems to be for only VB. I was kind of hopping there was something similar for C#. (As far as I can tell it acts the opposite of the AlwaysOnTop setting(which in itself is basically what things like TaskManager use. Apparently.))
|
|
|
|
|
If you're writing a windows forms app, the TextBox control has a mechanism to let you select the text. Not so for web pages, or so it seems, anyway.
My desire doesn't seem that complex. I have to manually set focus to controls on occasion, and when I do I'd like to select the complete contents as well. Can't seem to find a way to do this.
The browser does this by default if you just tab through controls. However, if you manually set the focus, the text is unselected and I can find no mechanism to manually select it.
Anyone know the workaround for this?
Thanks,
|
|
|
|
|
Hi,
Not sure, but Javascript might do the trick. You can select all the text on click event.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Hello All,
How can i do in order to change a permission for an user in a registry key.
How to do it programatically.
Thanks in advance...
Regards,
|
|
|
|
|
What would be the legit reason for this?
|
|
|
|
|
Hi guys, first post, i'm just getting to grips with c#.net finally, should be a pro at the end of the week, anyway, i'm pretty used to vb.net so that might be why im having trouble.
Here is the issue:
Say for example my program.cs opens a form, we will call that Main_Form, and from Main_Form, i load another form, we will call this new form Sub_Form, how can i change the height of Main_Form from the code of Sub_Form, Main_Form is already open, i dont want to do a show dialog because that only good if the forms not open right?, i just want to access the properys of the already open Main_Form from the Sub_Form, i'm not really after changeing the height to be honest, i just can't work out how to play with an already open form without making a new instance of it.
I've done this in VB.net just can't do the same in C#.net, many thanks guys.
Si
|
|
|
|
|
Hello,
You need to have an reference of Main_Form in your Sub_Form.
You can do that with an property:
public Main_Form mymainform
{
get ...
set...
}
The Main_Form gives its instance to the Sub_Form property
//Main_Form code
this.sub_form.mymainform = this;
Your Sub_Form can now change Main_Form properties, like:
this.mymainform.Height = ...;
But there are much more elegant posibilities discriped in this article from Colin Angus Mackay:
http://www.codeproject.com/dotnet/passingvaluesbetweenforms.asp[^]
Hope that helps you.
All the best,
Martin
|
|
|
|
|
Hi,
Why do the following statement not working:
DataColumn.Expression = "Value1 + \n + Value2"
Try to assign two strings which is below each other for multi-line text.
thanks
|
|
|
|
|
Fixed it myself. Sorry.
DataColumn.Expression = "ProjectCode +'"+Environment.NewLine+"' + ProjectDesc";
|
|
|
|
|
hi everybody,
how can i change default exe icon in VC#.net
Thanks
|
|
|
|
|
Select the project, Right Click -> Properties
On the properties page
under the resource section there is an option for Icon.
set that by browsing to the ico file.
hope that works for u.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Just want to know if anyone here has any experience with Ghost Installer?
I downloaded the free version get the files added but when I run the setup.exe I get an error at the first file it tries to copy, says that it can't install file.
My apologies if this isn't in the correct forum, wasn't quite sure where it would fit.
Thanks in advance
He who laughs last is a bit on the slow side
|
|
|
|
|