473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dataset - DataGrid - ComboBox

What's wrong here?

Sub ShowDG()
DsIllness1.Clear()
DsIllness1.tblIllness.illIDColumn.ColumnMapping = MappingType.Hidden
DsIllness1.tblIllness.illDescColumn.ColumnMapping = MappingType.Hidden

Try
OleDbDataAdapter1.Fill(DsIllness1)
dg.DataSource = DsIllness1.DefaultViewManager
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Sub Check()
If comboLang.SelectedIndex = 0 Then
DsIllness1.tblIllness.illNameEColumn.ColumnMapping = MappingType.Hidden '
**********LINE 1
dg.RightToLeft = RightToLeft.Yes ' *********LINE 2
Else
DsIllness1.tblIllness.illNameFColumn.ColumnMapping = MappingType.Hidden '
**********LINE 3
dg.RightToLeft = RightToLeft.No ' **********LINE 4
End If
ShowDG()
End Sub

Private Sub comboLang_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles comboLang.SelectedIndexChanged
Check()
End Sub
When I select an item of combo box, it goes to Check() sub, but just LINE2
and LINE4 works and

LINE 3 or LINE 4 does not work.
--
Saber S.
http://maghalat.com
Nov 21 '05 #1
7 1551
Saber,

I think that there is more wrong, however to start, a combobox selectedindex
change event starts already to fire if you set the datasource of a combobox.

Therefore are a lot of solutions. One of the easiest ones is to set a switch
that you set to false or true if the combobox is complete initialized.

(The defaultview is often a datasource, I never saw the defaultviewmanager
for that)

I hope this helps,

Cor
Nov 21 '05 #2
> Saber,

I think that there is more wrong, however to start, a combobox
selectedindex change event starts already to fire if you set the
datasource of a combobox. Thanks Cor,
You mean if I select an item of combobox in runtime, its SelectedIndex
property
doesn't changes?

Therefore are a lot of solutions. One of the easiest ones is to set a
switch that you set to false or true if the combobox is complete
initialized. Would you please tell me more about it: "if the combobox is complete
initialized."
I'm not sure if I get whay you say. What if I have 3 items in combobox?
(The defaultview is often a datasource, I never saw the defaultviewmanager
for that) Well, you see it now. ;) (kidding)
I saw your sample here:
http://www.windowsformsdatagridhelp....3-a3539697edbd

You create a datatable, and then: DataGrid1.DataSource = dt.DefaultView

What if doing it without datatable?
defaultviewmanager works fine, is it really a mistake to use it here?

I hope this helps,
It really helps.
Cor

Nov 21 '05 #3
Saber,

Very roughly

Globaly
Private loaded as boolean

In the load event
combobox1.datasource = mytable
etc
loaded = true

In your selected index change event
if loaded then....................
do what you want to do with the combobox.

end if

I hope this helps,

Cor
Nov 21 '05 #4
Sorry Cor,
I think I couldn't tell you what I want to do.
There is a combobox with 2 items: Persian, English
The items in this combobox are just this 2 values.
When user, selects English, actually he selects index 1
and Persian's index is 0.
I've two columns in a table of my database, illNameF which
is Persian illness names and illNameE is English illness names.
I want when user selects Persian in combobox, hide illNameE
in datagird and when selects English, hide illNameF.
also there are two other columns in that table, they will hide easily.
(by the code I posted already)
in Page Load event, when I set combobox.selectedindex to 0 or 1, it
hides illNameE or illNameF but in runtime when I change combobox item,
it doesn't hides other column.

--
Saber S.
http://maghalat.com
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Saber,

Very roughly

Globaly
Private loaded as boolean

In the load event
combobox1.datasource = mytable
etc
loaded = true

In your selected index change event
if loaded then....................
do what you want to do with the combobox.

end if

I hope this helps,

Cor

Nov 21 '05 #5
Saber,

If I understand you well, than would I first of all not use a combobox for
that, much to difficult for you and the user while the checkbox and the
radiobutton are made for what you tell.

Your problem is easily to solve with setting the mapping to hidden. That has
to be in advance of setting the datasource.

I made this morning a sample for that for somebody else. Have a look at
that.

http://www.windowsformsdatagridhelp....6-0ea05b3e1bee

I hope this helps,

Cor

Nov 21 '05 #6
Cor,
I think the error is somewhere else.
I deleted the combobox and simply put 2 buttons on the form.
Sub ShowDG()
DsIllness1.Clear()
DsIllness1.tblIllness.illIDColumn.ColumnMapping = MappingType.Hidden
DsIllness1.tblIllness.illDescColumn.ColumnMapping = MappingType.Hidden
Try
OleDbDataAdapter1.Fill(DsIllness1)
dg.DataSource = DsIllness1.DefaultViewManager
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub btnFullList_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnFullList.Click

OleDbDataAdapter1.SelectCommand.CommandText = "SELECT illDesc, illID,
illNameE, illNameF FROM tblIllness"
DsIllness1.tblIllness.illNameFColumn.ColumnMapping = MappingType.Hidden
dg.RightToLeft = RightToLeft.No
ShowDG()

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

OleDbDataAdapter1.SelectCommand.CommandText = "SELECT illDesc, illID,
illNameE, illNameF FROM tblIllness"
DsIllness1.tblIllness.illNameEColumn.ColumnMapping = MappingType.Hidden
dg.RightToLeft = RightToLeft.Yes
ShowDG()

End Sub
When I click btnFullList, it is OK and it does what I desire.
also When I click Button1, it is OK and it does what I desire.

But the problem is here, I click btnFullList and then Button1 or vise versa.
It just changes RightToLeft, and previous ColumnMapping doesn't changes.
I need a way (a sub routine) to reset ColumnMapping=MappingType.Hidden

Thanks

--
Saber S.
http://maghalat.com
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Saber,

If I understand you well, than would I first of all not use a combobox for
that, much to difficult for you and the user while the checkbox and the
radiobutton are made for what you tell.

Your problem is easily to solve with setting the mapping to hidden. That
has to be in advance of setting the datasource.

I made this morning a sample for that for somebody else. Have a look at
that.

http://www.windowsformsdatagridhelp....6-0ea05b3e1bee

I hope this helps,

Cor

Nov 21 '05 #7
Saber,

Why don't you than not set the mapping type to another one?

http://msdn.microsoft.com/library/de...classtopic.asp

I did not test which however that you can do yourself in my opinon.

I hope this helps,

Cor
Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gamze | last post by:
Hi, How can i get values from datagrid to combobox and should select the same name as in datagrid row on the combobox control In my vb.net windows application ,i have combobox which is...
6
by: Omar | last post by:
When I try to databind my comboBox (specifically field "emplcode") to a filled dataset , the contents of the comboBox displays a bunch of "System.Data.DataRowView". I assume the amount of times...
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
2
by: Bill C. | last post by:
Hi, I'm trying to implement a ComboBox drop-down column for a DataGrid. When a cell is selected in the ComboBox column I overlay a ComboBox over the cell and call: this.comboBox.Show();...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
2
by: Robert | last post by:
I'm sure this is a fairly basic question, but I've been looking all over the web for days for suggestions on how to do this. I've got a datagrid that's bound to a dataset on my form. It includes...
4
by: youngster94 | last post by:
Hi all, I'm having a little trouble with some code Im writing and Im thinking there has to be an easy fix. What Ive done is fill a dataset via 3 odbcdataadapters. The dataset is also the...
13
by: Saber | last post by:
I did a lot of searches and read something about datagrids. But I couldn't find the answer of my simple question, how can I show only my desired columns of a table? for example I wrote this sql...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.