|
My only suggestion would be to move any position calculations to outside the Paint function because that is called more often. I.e. do as few mathematical calculations for the positioning / size of the elements in the Paint event, do that inside the Resize .
|
|
|
|
|
Hello,
I m using Visual Studio 2005.Doing windows project in C#.Net.In that
i m using popup window forms.All details in text boxes are getting filled.But combo box and list boxes are not showing correct records?
I m taking records from database (sql server 2000) depending on the id of selected record from the datagrid.I m using Binding navigator.On that i have taken command button.On click event of that button i m displaying another form,in that form i m getting above explained problem.
I have debugged & found that all values are getting retrived correctly.It showing the value of selected index correctly also value in selected text field is also correct.Then why Combobox & ListBox contents are not getting updated.....
hello
|
|
|
|
|
Can you post the relevant pieces of code please, it'd be a great help in trying to help you diagnose this problem.
|
|
|
|
|
hmmmm!!!I m Using BindingNavigator on user control.On that i have taken Button,on click event of that i m displaying another windows form using showdialog...
hello
|
|
|
|
|
Can you post the code which is surrounding the ShowDialog, the bits that set the combo boxes etc.
|
|
|
|
|
private void bindingNavigatorCreateResumeItem_Click(object sender, EventArgs e)
{
int EmployeeId = 0;
DataSet dsEmlpoyee;
dsEmlpoyee=(DataSet)((BindingSource)grdVwEmpOverview.DataSource).DataSource;
if (grdVwEmpOverview.CurrentRow!=null)
{
EmployeeId = BaseObject.GetValue_Int32(grdVwEmpOverview.CurrentRow.Cells["EmployeeId"].Value);
string EmpName = Convert.ToString(grdVwEmpOverview.CurrentRow.Cells["ShortName"].Value);
frmEmployeeResume ofrmEmployeeResume = null;
ofrmEmployeeResume = (frmEmployeeResume)CCommonFunction.ShowChild(frmMain.Me, CConfiguration.ChildForms.EMPLOYEECREATERESUME);
ofrmEmployeeResume.ClearForm();
ofrmEmployeeResume.ShowEmployeeDetails(ref dsEmlpoyee, EmployeeId);
ofrmEmployeeResume.ShowDialog();
}
}
//ShowEmployeeDetails on other form.
public void ShowEmployeeDetails(ref DataSet DsEmployee, int EmployeeId)
{
DataRow[] drRequest = null;
try
{
m_EmpId = 0;
drRequest = DsEmployee.Tables[0].Select("fldEmployeeId=" + EmployeeId);
if (drRequest.Length > 0)
{
m_EmpId = EmployeeId;
txtPersonalno.Text = drRequest[0]["fldEmployeePersonnelNo"].ToString();
txtShortname.Text = drRequest[0]["fldEmployeeShortName"].ToString();
txtFirstname.Text = drRequest[0]["fldEmployeeFirstName"].ToString();
txtSurname.Text = drRequest[0]["fldEmployeeSurname"].ToString();
cmbStatus.SelectedIndex = Convert.ToInt32(drRequest[0]["fldEmployeeStatus"].ToString());
cmbMaritalStatus.SelectedIndex = Convert.ToInt32(drRequest[0]["fldEmployeeMaritalStatus"].ToString());
cmbCitizenship.SelectedValue = Convert.ToInt32(drRequest[0]["fldEmployeeCitizenship"].ToString());
cmbPAddrCountry.SelectedValue = Convert.ToInt32(drRequest[0]["fldEmployeePAddrCountryId"].ToString());
}
}
catch (Exception ex)
{
StaticUtils.LogExceptionAndContinue(ex, "frmEmployeeDetails.ShowRequestDetails()");
}
}
-- modified at 7:04 Wednesday 14th February, 2007
Help Please!!!
|
|
|
|
|
Two questions, are the comboboxes databound in anyway? I'm guessing not.
Do you have the STAThread attribute applied to your Main function? If not it can produce some really really bizarre behaviour.
|
|
|
|
|
Yes i have applied the STAThread attribute to main function.
During debugging it shows the records correctly......Then why combo & list box contents r not showing correct value...
Help Please
|
|
|
|
|
One thing I noticed is for these two lines:
cmbCitizenship.SelectedValue = Convert.ToInt32(drRequest[0]["fldEmployeeCitizenship"].ToString());
cmbPAddrCountry.SelectedValue = Convert.ToInt32(drRequest[0]["fldEmployeePAddrCountryId"].ToString()); It'd be better as .SelectedValue = (int)(drRequest[0]["fieldname"]); Because what your code is doing is converting an integer (stored in object form because of being late-bound) to a string and then back again, where as if you just cast it it'll be faster and happier.
The code looks correct, the only thing I can think of at the moment is how have the combo boxes been populated? Are they bound to the data source?
|
|
|
|
|
Yes,combobox & listbox bound to the datasource....during page load
|
|
|
|
|
I just helped out someone who has a similar problem with data binding, try running the code without the debugger attached (Ctrl+F5), this worked for his solution for some odd reason. Alternatively you could try calling ComboBox.Refresh() to force it to redraw itself.
|
|
|
|
|
|
how i will change windows date time format? It should change the system's date time format too.
-- modified at 5:39 Wednesday 14th February, 2007
|
|
|
|
|
Format Info
DateTime objDate = DateTime.Now;<br />
String strFormatedDate = objDate.ToString("yyyy-mm-dd HH:mm:ss");
Edit:
Wrong topic? OS/SysAdmin
Anyway you can change the windows date time format in Start->Configuration Screen->Languagesettings
There you can change all currency and formats...
-- modified at 5:41 Wednesday 14th February, 2007
|
|
|
|
|
Check the registry key in regedit: HKEY_CURRENT_USER\Control Panel\International
Here are all the windows format settings stored. To edit this value's from within your program you have to use the Microsoft.Win32.Registry class.
PS. When you want to edit/update an value you need to use the method CreateSubKey and not OpenSubKey
This code will change the long date time representation of windows to DayName DayOfWeek MonthName 4-digit Year:
RegistryKey objReg = Registry.CurrentUser.CreateSubKey(@"\Control Panel\International");<br />
objReg.SetValue("sLongDate", "dddd d MMMM yyyy");
Hope this is usefull...
|
|
|
|
|
Hai all,
In my project i want to generate an excel report from datgrid...
i just want to export my contents of datagrid to excel... can anyone
help me with c# sample codings.......
with Regards,
Imthiyas Ahamed.A
|
|
|
|
|
at first you have to select the reference named:microsoft excel 10.0 object lib and microsofr office 10.0 object lib
then u may use this or some thing like this
==>
string Path = @fileName;
// initialize the Excel Application class
Excel.ApplicationClass app = new ApplicationClass();
// create the workbook object by opening the excel file.
Excel.Workbook workBook = app.Workbooks.Open(Path,0,true,5,pass1,pass2, true,
Excel.XlPlatform.xlWindows,"\t",false,false,0,true,1,0);
// get the active worksheet using sheet name or active sheet
Excel.Worksheet workSheet = (Excel.Worksheet)workBook.ActiveSheet;
// This row,column index should be changed as per your need.
// i.e. which cell in the excel you are interesting to read.
int row=2;
while ( ((Excel.Range)workSheet.Cells[row,1]).Value2 != null )
{
for(int a=1;a<=col;a++)
{
if(((Excel.Range)workSheet.Cells[row,a]).Value2 != null )
totSiz[row-2,a]= ((Excel.Range)workSheet.Cells[row,a]).Value2.ToString();
}
row++;
}
|
|
|
|
|
how can i get ipaddress into database?
String strHostName;
//= new String("");
if (args.Length == 0)
{
// Getting Ip address of local machine...
// First get the host name of local machine.
strHostName = Dns.GetHostName();
//MessageBox.Show(strHostName);
}
else
{
strHostName = args[0];
}
// Then using host name, get the IP address list..
IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
IPAddress[] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
strip = addr[i].ToString();
//MessageBox.Show(strip);
}
Is it proper?It is stored in 'strip' variable, which i have to call later in a function. can u get it?
How shu i declare these : args,Dns,args[0],IPHostEntry,IPAddress[] ?
thanx
|
|
|
|
|
define variabel in top of page. so it stored permanently while u'r application in running mode.
write this on top of page.(global variabel define)
if think.
public string var1;
|
|
|
|
|
|
all string?
i didn't got u'r question. send me again.
|
|
|
|
|
Perhaps this should help you...
public string strHostName="";<br />
public string [] args=null;<br />
public IPHostEntry ipEntry =null;<br />
IPAddress[] addr=null;<br />
.<br />
.<br />
.<br />
.<br />
.<br />
.<br />
if (args.Length == 0)<br />
{<br />
strHostName = Dns.GetHostName();<br />
}<br />
else<br />
{<br />
strHostName = args[0];<br />
}<br />
<br />
ipEntry = Dns.GetHostByName(strHostName);<br />
addr = ipEntry.AddressList;<br />
for (int i = 0; i < addr.Length; i++)<br />
{<br />
strip = addr[i].ToString();<br />
}
I Love SQL
|
|
|
|
|
I have a form with a number of user controls on, however the form seems to keep corrupting. I don’t have the problem with any forms that don’t have user controls, and another dev here has the same problems on another app (different user controls as well).
This is the error that I get when I try to load the form in the designer
http://img157.imageshack.us/my.php?image=formerroruu9.jpg
Any suggestions
I am using VS 2005
-- modified at 4:55 Wednesday 14th February, 2007
|
|
|
|
|
Hello,
The designer calls the Constructor and also the setters of properties if they are set, from your usercontrol.
In your case you whant to access an object wich is not created (instanziated) yet, therefore you get this null ref Exception.
You first have to find the point in the usercontrol where the exception is thrown:
You could start a second instance of your project and then connect at youre first instance.
After that you should set a breakpoint in your controls constructor, and then open the form (designer) in the first project.
Or go threw the code and look for unsafe code (like access without a != null if statement).
Once you find your problem please don't use the "DesignMode" property (like some programers would recommend) as a workaround, make it run by changing maybe the design or use an if statement.
Hope that helps!
All the best,
Martin
|
|
|
|
|
Thanks for your reply,
Firstly can you explain how i do this i a little more detail
"You could start a second instance of your project and then connect at youre first instance.
After that you should set a breakpoint in your controls constructor, and then open the form (designer) in the first project."
secondally, one minuate that project is fine then, i rebuild it and it breaks, why would it not be consistant?
Thanks
Mark
|
|
|
|