|
Try this -
'<html><DIV bgcolor="yellow"><font color="red">my listbox item</font></DIV></html>'
It will produce yellow background color for the specific listbox item.
You can do this when setting 'String' property value for each listbox item.
"Alric Gta" <alric2rei@yahoo.com> wrote in message <gsi0v5$g82$1@fred.mathworks.com>...
> I have on my form:
> -- 1 Listbox, 2 pushbuttons, 1 edit
> =======================================
> OBS:
>
> Is this even posible and if yes how exactly somebody modifie my prg or give me some
> example prg that do what i want.
>
> Push Button 2 = Load a TXT file
> Push Button 1 = Compare EDit/Listbox
> =======================================
> I want to :
>
> a) Compare what is written in Edit with what a have in LIstbox
> --- this is done NO PRoblem Here.
> b) When it match what is in the Edit with the line in LISTbox , -- I want that specific
> line in LIstbox to turn in GREEN === Big Problem
> -------------------------------------------------------------------------------------------------------------
> Here's a picture with what i want exact:
>
> http://i361.photobucket.com/albums/oo54/Rikom/test.jpg
>
> [IMG]http://i361.photobucket.com/albums/oo54/Rikom/test.jpg[/IMG]
> ==================================================
> My Program:
>
>
>
> % --- Executes just before Green_Detection is made visible.
> function Green_Detection_OpeningFcn(hObject, eventdata, handles, varargin)
> % This function has no output args, see OutputFcn.
> % hObject handle to figure
> % eventdata reserved - to be defined in a future version of MATLAB
> % handles structure with handles and user data (see GUIDATA)
> % varargin command line arguments to Green_Detection (see VARARGIN)
>
> % Choose default command line output for Green_Detection
> handles.output = hObject;
>
> % Update handles structure
> guidata(hObject, handles);
>
> % UIWAIT makes Green_Detection wait for user response (see UIRESUME)
> % uiwait(handles.figure1);
>
>
> % --- Outputs from this function are returned to the command line.
> function varargout = Green_Detection_OutputFcn(hObject, eventdata, handles)
> % varargout cell array for returning output args (see VARARGOUT);
> % hObject handle to figure
> % eventdata reserved - to be defined in a future version of MATLAB
> % handles structure with handles and user data (see GUIDATA)
>
> % Get default command line output from handles structure
> varargout{1} = handles.output;
>
>
> % --- Executes on selection change in listbox1.
> function listbox1_Callback(hObject, eventdata, handles)
> % hObject handle to listbox1 (see GCBO)
> % eventdata reserved - to be defined in a future version of MATLAB
> % handles structure with handles and user data (see GUIDATA)
>
> % Hints: contents = get(hObject,'String') returns listbox1 contents as cell array
> % contents{get(hObject,'Value')} returns selected item from listbox1
>
>
> % --- Executes during object creation, after setting all properties.
> function listbox1_CreateFcn(hObject, eventdata, handles)
> % hObject handle to listbox1 (see GCBO)
> % eventdata reserved - to be defined in a future version of MATLAB
> % handles empty - handles not created until after all CreateFcns called
>
> % Hint: listbox controls usually have a white background on Windows.
> % See ISPC and COMPUTER.
> if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
> set(hObject,'BackgroundColor','white');
> end
>
>
>
> function edit1_Callback(hObject, eventdata, handles)
> % hObject handle to edit1 (see GCBO)
> % eventdata reserved - to be defined in a future version of MATLAB
> % handles structure with handles and user data (see GUIDATA)
>
> % Hints: get(hObject,'String') returns contents of edit1 as text
> % str2double(get(hObject,'String')) returns contents of edit1 as a double
>
>
> % --- Executes during object creation, after setting all properties.
> function edit1_CreateFcn(hObject, eventdata, handles)
> % hObject handle to edit1 (see GCBO)
> % eventdata reserved - to be defined in a future version of MATLAB
> % handles empty - handles not created until after all CreateFcns called
>
> % Hint: edit controls usually have a white background on Windows.
> % See ISPC and COMPUTER.
> if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
> set(hObject,'BackgroundColor','white');
> end
>
>
> % --- Executes on button press in pushbutton1.
> function pushbutton1_Callback(hObject, eventdata, handles)
>
> a=get(handles.edit1,'String');
> prev_str = get(handles.listbox1,'String');
> len = length(prev_str);
>
> for i=1:len
> set(handles.listbox1,'Value',i); %selecteaza in LIstBX val curenta cu care se compara
> if strcmp(prev_str(i),a)== 1
>
>
> % set(handles.listbox1,'Value',('BackgroundColor','g'),i);
>
>
> return
> else
> if i==len % Daca nu sa gasit nici o potrivire
> errordlg('Nu sa gasit in Baza de Date!','Eroare');
> end
> end
>
> pause(1);
> end
>
> % --- Executes on button press in pushbutton2.
> function pushbutton2_Callback(hObject, eventdata, handles)
>
> [fname,pname] = uigetfile('*.txt');
> X = textread(fullfile(pname,fname),'%s','delimiter','\n');
> set(handles.listbox1,'string',X)
>
> Thanx
|