|
A quick solution would be to use a state variable. Set it to true once you have loaded your data and check it within your SelectedValueChanged before you do anything else within it.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks for all the suggestions. It seams that when you load the combo box (atleast with a dataset) it fires off the selectedItem and selectedvalue events, and maybe other combo box events.
The selectedIndex stayed at 0 all the time so the if(combobox.selectedindex > 0) did work, but sense I was using index 0 for "All" to not filter that category it wasn't going to work for me.
So after many cans of A&W Root Beer, I moved the lines that sets the events for both combo boxs under the last item in the form load event which was the loading of the datagrid. It seams to be working perfectly.
Thanks again for all the suggestions,
JefferyS
|
|
|
|
|
Hi, i'm working on improving the effeciency on a certain block of code and was wondering if any tools existed to see if i'm making positive contributions to the code.
|
|
|
|
|
There is ANTs.
/\ |_ E X E GG
|
|
|
|
|
Do you know Rational Quantify (part of Rational XDE)?
|
|
|
|
|
You will have to analyse your algorhitm then. No point in attempting to make code faster with trial and error. Have a plan.
top secret xacc-ide 0.0.1
|
|
|
|
|
I am programatically building a dataset that populates a datagrid. I need to then specfify the column widths for each column. However, the grid control ignores my input. I first tried setting the widths under TableStyles/GridColumnStyles. That was ignored so I figured it was because I wasn't populating the grid from a predefined datasource. So then I tried progammatically. Still nothing. Below is my code. The grid should only have one table in it. The grid populates correctly, it just doesn't format the widths of the columns. The dataset only returns 3 columns.
//get the data
dsResults = SqlHelper.ExecuteDataset(Conn,CommandType.StoredProcedure,"usp_GetSearchResultsSel",new SqlParameter("@Description", txtDescription.Text),new SqlParameter("@SearchParameters", cboSearchParam.SelectedText));
//populate the grid
dgResults.DataSource = dsResults.Tables[0].DefaultView;
//settings for grid
dgResults.TableStyles[0].GridColumnStyles[0].Width=200;
dgResults.TableStyles[0].GridColumnStyles[1].Width=50;
dgResults.TableStyles[0].GridColumnStyles[2].Width=100;
dgResults.ReadOnly=true;
|
|
|
|
|
I am assuming that its a winform application:
Peter8675309 wrote:
//get the data
dsResults = SqlHelper.ExecuteDataset(Conn,CommandType.StoredProcedure,"usp_GetSearchResultsSel",new SqlParameter("@Description", txtDescription.Text),new SqlParameter("@SearchParameters", cboSearchParam.SelectedText));
dgResults.TableStyles.Clear();
DataTableStyle tabStyle1=new DataTableStyle();
tabStyle1.MappingName = <mapping name="">
//populate the grid
dgResults.DataSource = dsResults.Tables[0].DefaultView;
dgResults.TableStyles.Add(tabStyle1);
//settings for grid
dgResults.TableStyles[0].GridColumnStyles[0].Width=200;
dgResults.TableStyles[0].GridColumnStyles[1].Width=50;
dgResults.TableStyles[0].GridColumnStyles[2].Width=100;
dgResults.ReadOnly=true;
try this :
dsResults = SqlHelper.ExecuteDataset(Conn,CommandType.StoredProcedure,"usp_GetSearchResultsSel",new SqlParameter("@Description", txtDescription.Text),new SqlParameter("@SearchParameters", cboSearchParam.SelectedText));
dgResults.DataSource = dsResults.Tables[0]; <<-- maybe!!!
dgResults.TableStyles[0].GridColumnStyles[0].Width=200;
dgResults.TableStyles[0].GridColumnStyles[1].Width=50;
dgResults.TableStyles[0].GridColumnStyles[2].Width=100;
dgResults.ReadOnly=true;
"Creating tomorrow's legacy systems today.....
.... One CRISIS at a time!" -- Unknown
"If you build it....
.....BUGS will come!" -JB
this.Dispose();
"A Bug is a piece of <sup> code </sup> that knows whatz its purpose"
|
|
|
|
|
Yes this is a windows form. If I add in
dgResults.TableStyles[0].GridColumnStyles.Clear();
I get an 'index out of range' error unless I prepopulate the TableStyles of the grid prior. I took a look at the code at section 5.3.2 from
http://www.codeproject.com/csharp/PracticalGuideDataGrids4.asp#_Toc56951053.
This functions (if I set the dt equal to me dataset.Column), but it still doesn't modify the column widths.
Thanks for your quick reply.
|
|
|
|
|
Peter8675309 wrote:
dgResults.TableStyles[0].GridColumnStyles.Clear();
clear the table styles, not the gridcolumnstyles.
Well it seems to work for me:
this.dataGrid1.DataSource=null;
this.dataGrid1.TableStyles.Clear();
DataTableStyles tab1=new DataTableStyles();
tab1.MappingName="ShoppingTables";
this.dataGrid1.TableStyles.Add(tab1);
this.dataGrid1.DataSource= DbHelper.GetDataSet(blah...blah).Tables[0];
this.dataGrid1.TableStyles[0].GridColumnStyles[0].Width = 50;
this.dataGrid1.TableStyles[0].GridColumnStyles[1].Width = 0;
this.dataGrid1.AllowNavigation = false;
this.dataGrid1.AllowSorting = false;
if( this.dataGrid1.VisibleRowCount > 0)
this.dataGrid1.Select(0);
Let me know if this works for you, in my case i am making the width of of 1st column to 50 and 2nd column hidden.
"Creating tomorrow's legacy systems today.....
.... One CRISIS at a time!" -- Unknown
"If you build it....
.....BUGS will come!" -JB
this.Dispose();
"A Bug is a piece of <sup> code </sup> that knows whatz its purpose"
|
|
|
|
|
Where is datatablestyles defined? I don't see it in the help of on MS's site. How is this class defined? If it comes from WebControls, I am working on a windows form.
Thanks for your help.
|
|
|
|
|
Peter8675309 wrote:
datatablestyles
I sincerely apologize for misleading you by datatablestyles. its actually
DataGridTableStyles. Its part of the System.Windows.Forms namespace.
Hope this helps, again i am sorry for the wrong class name fiasco!
"Creating tomorrow's legacy systems today.....
.... One CRISIS at a time!" -- Unknown
"If you build it....
.....BUGS will come!" -JB
this.Dispose();
"A Bug is a piece of <sup> code </sup> that knows whatz its purpose"
|
|
|
|
|
No worries. That makes more sense. It still doesn't work. I must have the MappingName messed up some how. Whether I do this programmatically or through the properties window, my changes don't take.
Thanks
|
|
|
|
|
I posted here yesterday about a problem I couldn't get my head around: a server would publish an object , a client would connect to it successfully, client would exit, client would attempt to connect again and would hang.
Today I wrote a very very simple test project to see if I could reproduce the problem in the simplest of environments. It turns out I could reproduce the problem with a very basic environment, doing a simple publish server object & activate on client. I would start up the server in debug mode (Visual Studio's right-click->Debug->Start New Instance) and then would do the same for the client, exit the client, then restart the client. Voila it would hang the 2nd time.
So I wondered whether this was a bug in the 2.0 beta framework. I took the code over and recompiled in Visual Studio 2003. Unlike VS 2005, whenever you close one of the debugging projects, all debugged instances are closed in 2003, so I had to manually execute the server then the client. It ran fine.
I thought for sure now that it was a 2.0 beta bug. Then it occurred to me that since the method of actually executing these test projects were different (2005 I could close the client while in debug mode while keeping the server in debug mode, whereas 2003 closes all debugging executables when one of them exits). So, I tried manually running the 2.0 executables. And whaddya know, it works fine.
To summarize, Visual Studio 2005, at least the express edition, has an issue with debugging multiple running executables simultaneously; it requests input (and suspends all execution) from the remaining debugging executable (the server in this case) when the other debugging executable (the client) has stopped debugging and exited.
I've uploaded a example case at http://www25.brinkster.com/swamii/RemotingBugInVS2005.zip
And the name on the zip is misleading :-p Not really a Remoting bug, just a bug or design flaw that happened to occur while I was writing some remoting code.
Thanks to Heath Stewart, Brian Gideon, and Tom Larsen for offering suggestions when this problem occurred yesterday.
Judah Himango
|
|
|
|
|
beta software are meant to have bugs, else it would have been released already. This also probably a known bug. Refer to the proper bug submission on the beta site.
top secret xacc-ide 0.0.1
|
|
|
|
|
beta software is....
/\ |_ E X E GG
|
|
|
|
|
How can I get the PropertyGrid to display numbers in hex like you can in the VS debugger?
I'm sure that it can be done on a per object basis but I want general dynamically switchable.
|
|
|
|
|
Hi,
I am looking to get a list of users, specifically email addresses from an NT/2003 domain. Is there an easy way of doing this coz i have absolutely no idea how to approach the problem.
Thanks.
|
|
|
|
|
I'm implementing a background thread that updates the poistion of the Label control on a Form. I was told by Leppie that I was not correctly implementing the ISynchronizeInvoke interface. Can anyone tell me what I'm doing wrong ?
private delegate void ScrollThreadDelegate();
...
...
ScrollThread = new Thread(new ThreadStart(ScrollThreadFunction));
ScrollThread.IsBackground=true;
ScrollThread.Start();
...
private void ScrollThreadFunction()
{
while(RunScrollThread)
{
if(lbSongInfo.InvokeRequired)
{
this.lbSongInfo.Invoke(new ScrollThreadDelegate(this.ShowScrollText));
}
Thread.Sleep(50);
}
}
private void ShowScrollText()
{
if(lbSongInfo.Location==SongInfoEnd)
lbSongInfo.Location=SongInfoStart;
Point CurPos = new Point(lbSongInfo.Location.X,lbSongInfo.Location.Y);
CurPos.Offset(-1,0);
lbSongInfo.Location=CurPos;
}
|
|
|
|
|
Hi people,
I would be the happiest man on Earth if someone tells me how can I change the decimal symbol programmatically. I mean as my program starts i want to parse the strings in a way that the dot is always the decimal symbol no matter what regional settings are set on the PC.
Kamen Boyadjiev
|
|
|
|
|
You could get hold of a copy of a NumberFormatInfo object and modify the NumberDecimalSeparator to the desired character.
NumberFormatInfo nfi = Thread.CurrentThread.CurrentUICulture.NumberFormat.Clone();
nfi.NumberDecimalSeparator = ".";
string myFormattedDouble = myDouble.ToString(nfi); The above assumes the existance of a double called myDouble
Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Hi Colin,
thank you for your fast reply. This is really good idea but actually it does not help in my case. Actually I did not expressed my problem quite well. If I have a in a TextBox the string "1.2" I need to parse it as a 1.2 number and the problem is that when I have different decimal symbol not the dot I get quite astonishing numbers, such as for example 1200 by a german language settings due to that the dot is a digit grouping symbol . So my program must not take the german regional setting (if it is set so) but the english(united states) one.
Thank you in advance for any help
|
|
|
|
|
It is not too different from the code I provided above
CultureInfo ci = new CultureInfo("en-US");
NumberFormatInfo nfi = ci.NumberFormat;
double myParsedDouble = myDouble.Parse(txtMyTextBox.Text, nfi);
As the US English Culture already has the correct number format for parsing 1.2 as six fifths rather than 1200 you don't need to create a clone of NumberFormatInfo object and modify it.
Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Well Colin that sure would help. Really thank you for that help. Actually quite stupid from me that I have not noticed that to Parse could be passed a CultureInfo too. Really much obliged
|
|
|
|
|
Opps... Might have helped if I actually read into the System.Globalization namepsace first...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|